javax.swing.JSlider.getComponentOrientation()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中javax.swing.JSlider.getComponentOrientation()方法的一些代码示例,展示了JSlider.getComponentOrientation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSlider.getComponentOrientation()方法的具体详情如下:
包路径:javax.swing.JSlider
类名称:JSlider
方法名:getComponentOrientation

JSlider.getComponentOrientation介绍

暂无

代码示例

代码示例来源:origin: com.synaptix/SynaptixSwing

protected void recalculateIfOrientationChanged() {
  boolean ltr = slider.getComponentOrientation().isLeftToRight();
  if (ltr != leftToRightCache) {
    leftToRightCache = ltr;
    calculateGeometry();
  }
}

代码示例来源:origin: com.synaptix/SynaptixSwing

protected void recalculateIfOrientationChanged() {
  boolean ltr = slider.getComponentOrientation().isLeftToRight();
  if (ltr != leftToRightCache) {
    leftToRightCache = ltr;
    calculateGeometry();
  }
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
public void paintThumb(Graphics g) {
  Graphics2D graphics = (Graphics2D) g.create();
  // graphics.setComposite(TransitionLayout.getAlphaComposite(slider));
  Rectangle knobBounds = this.thumbRect;
  // System.out.println(thumbRect);
  graphics.translate(knobBounds.x, knobBounds.y);
  Icon icon = this.getIcon();
  if (this.slider.getOrientation() == JSlider.HORIZONTAL) {
    if (icon != null)
      icon.paintIcon(this.slider, graphics, -1, 0);
  } else {
    if (this.slider.getComponentOrientation().isLeftToRight()) {
      if (icon != null)
        icon.paintIcon(this.slider, graphics, 0, -1);
    } else {
      if (icon != null)
        icon.paintIcon(this.slider, graphics, 0, 1);
    }
  }
  // graphics.translate(-knobBounds.x, -knobBounds.y);
  graphics.dispose();
}

代码示例来源:origin: org.java.net.substance/substance

@Override
public void paintThumb(Graphics g) {
  Graphics2D graphics = (Graphics2D) g.create();
  // graphics.setComposite(TransitionLayout.getAlphaComposite(slider));
  Rectangle knobBounds = this.thumbRect;
  // System.out.println(thumbRect);
  graphics.translate(knobBounds.x, knobBounds.y);
  Icon icon = this.getIcon();
  if (this.slider.getOrientation() == JSlider.HORIZONTAL) {
    if (icon != null)
      icon.paintIcon(this.slider, graphics, -1, 0);
  } else {
    if (this.slider.getComponentOrientation().isLeftToRight()) {
      if (icon != null)
        icon.paintIcon(this.slider, graphics, 0, -1);
    } else {
      if (icon != null)
        icon.paintIcon(this.slider, graphics, 0, 1);
    }
  }
  // graphics.translate(-knobBounds.x, -knobBounds.y);
  graphics.dispose();
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
protected void calculateLabelRect() {
  super.calculateLabelRect();
  if ((this.slider.getOrientation() == JSlider.VERTICAL)
      && !this.slider.getPaintTicks()
      && this.slider.getComponentOrientation().isLeftToRight()) {
    this.labelRect.x += 3;
  }
}

代码示例来源:origin: com.synaptix/SynaptixSwing

} else {
  int offset = 0;
  if (!slider.getComponentOrientation().isLeftToRight()) {
    offset = labelBounds.width
        - label.getPreferredSize().width;

代码示例来源:origin: org.java.net.substance/substance

/**
 * Returns the rectangle of track for painting.
 * 
 * @return The rectangle of track for painting.
 */
private Rectangle getPaintTrackRect() {
  int trackLeft = 0, trackRight = 0, trackTop = 0, trackBottom = 0;
  if (this.slider.getOrientation() == SwingConstants.HORIZONTAL) {
    trackTop = 3 + this.insetCache.top + 2 * this.focusInsets.top;
    trackBottom = trackTop + this.getTrackWidth() - 1;
    trackRight = this.trackRect.width;
    return new Rectangle(this.trackRect.x + trackLeft, trackTop,
        trackRight - trackLeft, trackBottom - trackTop);
  } else {
    if (this.slider.getComponentOrientation().isLeftToRight()) {
      trackLeft = trackRect.x + this.insetCache.left
          + this.focusInsets.left;
      trackRight = trackLeft + this.getTrackWidth() - 1;
    } else {
      trackRight = trackRect.x + trackRect.width
          - this.insetCache.right - this.focusInsets.right;
      // this.slider.getWidth() - 8 - this.insetCache.right;
      trackLeft = trackRight - this.getTrackWidth() + 1;
    }
    trackBottom = this.trackRect.height - 1;
    return new Rectangle(trackLeft, this.trackRect.y + trackTop,
        trackRight - trackLeft, trackBottom - trackTop);
  }
}

代码示例来源:origin: com.synaptix/SynaptixSwing

InputMap getInputMap(int condition, JSlider slider) {
  if (condition == JComponent.WHEN_FOCUSED) {
    InputMap keyMap = (InputMap) DefaultLookup.get(slider, this,
        "Slider.focusInputMap"); //$NON-NLS-1$
    InputMap rtlKeyMap;
    if (slider.getComponentOrientation().isLeftToRight()
        || ((rtlKeyMap = (InputMap) DefaultLookup.get(slider, this,
            "Slider.focusInputMap.RightToLeft")) == null)) { //$NON-NLS-1$
      return keyMap;
    } else {
      rtlKeyMap.setParent(keyMap);
      return rtlKeyMap;
    }
  }
  return null;
}

代码示例来源:origin: com.synaptix/SynaptixSwing

InputMap getInputMap(int condition, JSlider slider) {
  if (condition == JComponent.WHEN_FOCUSED) {
    InputMap keyMap = (InputMap) DefaultLookup.get(slider, this,
        "Slider.focusInputMap"); //$NON-NLS-1$
    InputMap rtlKeyMap;
    if (slider.getComponentOrientation().isLeftToRight()
        || ((rtlKeyMap = (InputMap) DefaultLookup.get(slider, this,
            "Slider.focusInputMap.RightToLeft")) == null)) { //$NON-NLS-1$
      return keyMap;
    } else {
      rtlKeyMap.setParent(keyMap);
      return rtlKeyMap;
    }
  }
  return null;
}

代码示例来源:origin: com.synaptix/SynaptixSwing

protected boolean drawInverted() {
  if (slider.getOrientation() == JSlider.HORIZONTAL) {
    if (slider.getComponentOrientation().isLeftToRight()) {
      return slider.getInverted();
    } else {
      return !slider.getInverted();
    }
  } else {
    return slider.getInverted();
  }
}

代码示例来源:origin: com.synaptix/SynaptixWidget

} else {
  if (this.slider.getPaintLabels() || this.slider.getPaintTicks()) {
    if (this.slider.getComponentOrientation().isLeftToRight()) {
      trackLeft = trackRect.x + this.insetCache.left + this.focusInsets.left;
      trackRight = trackLeft + trackWidth - 1;
    if (this.slider.getComponentOrientation().isLeftToRight()) {
      trackLeft = (this.insetCache.left + this.focusInsets.left + this.slider.getWidth() - this.insetCache.right - this.focusInsets.right) / 2 - trackWidth / 2;
      trackRight = trackLeft + trackWidth - 1;

代码示例来源:origin: com.synaptix/SynaptixSwing

protected boolean drawInverted() {
  if (slider.getOrientation() == JSlider.HORIZONTAL) {
    if (slider.getComponentOrientation().isLeftToRight()) {
      return slider.getInverted();
    } else {
      return !slider.getInverted();
    }
  } else {
    return slider.getInverted();
  }
}

代码示例来源:origin: khuxtable/seaglass

/**
 * @param width
 * @param height
 * @param orientation
 * @param percentFilled
 * @return
 */
private Shape getValueShape(JComponent c,int width, int height, int orientation, double percentFilled) {
  Shape s; 
  JSlider slider = (JSlider)c;
  if ((orientation == JSlider.HORIZONTAL && slider.getComponentOrientation().isLeftToRight()) || slider.getInverted()) { 
     s = shapeGenerator.createRoundRectangle(1, 1, (int) (width*percentFilled), height - 2, CornerSize.ROUND_HEIGHT);
   } else {
     s = shapeGenerator.createRoundRectangle(width-(int)(width*percentFilled), 1, width, height - 2, CornerSize.ROUND_HEIGHT);
   }
  return s;
}

代码示例来源:origin: org.java.net.substance/substance

@Override
protected void calculateLabelRect() {
  super.calculateLabelRect();
  if ((this.slider.getOrientation() == JSlider.VERTICAL)
      && !this.slider.getPaintTicks()
      && this.slider.getComponentOrientation().isLeftToRight()) {
    this.labelRect.x += 3;
  }
  if (this.slider.getOrientation() == JSlider.VERTICAL) {
    this.labelRect.width = getHeightOfTallestLabel();
  }
}

代码示例来源:origin: com.synaptix/SynaptixSwing

public void installUI(JComponent c) {
  slider = (JSlider) c;
  checkedLabelBaselines = false;
  slider.setEnabled(slider.isEnabled());
  LookAndFeel.installProperty(slider, "opaque", Boolean.TRUE); //$NON-NLS-1$
  isDragging = false;
  trackListener = createTrackListener(slider);
  changeListener = createChangeListener(slider);
  componentListener = createComponentListener(slider);
  focusListener = createFocusListener(slider);
  scrollListener = createScrollListener(slider);
  propertyChangeListener = createPropertyChangeListener(slider);
  installDefaults(slider);
  installListeners(slider);
  installKeyboardActions(slider);
  scrollTimer = new Timer(100, scrollListener);
  scrollTimer.setInitialDelay(300);
  insetCache = slider.getInsets();
  leftToRightCache = slider.getComponentOrientation().isLeftToRight();
  focusRect = new Rectangle();
  focusInsets = new Insets(0, 0, 0, 0);
  contentRect = new Rectangle();
  labelRect = new Rectangle();
  tickRect = new Rectangle();
  trackRect = new Rectangle();
  thumbRect = new Rectangle();
  calculateGeometry(); // This figures out where the labels, ticks,
  // track, and thumb are.
}

代码示例来源:origin: com.synaptix/SynaptixSwing

public void installUI(JComponent c) {
  slider = (JSlider) c;
  checkedLabelBaselines = false;
  slider.setEnabled(slider.isEnabled());
  LookAndFeel.installProperty(slider, "opaque", Boolean.TRUE); //$NON-NLS-1$
  isDragging = false;
  trackListener = createTrackListener(slider);
  changeListener = createChangeListener(slider);
  componentListener = createComponentListener(slider);
  focusListener = createFocusListener(slider);
  scrollListener = createScrollListener(slider);
  propertyChangeListener = createPropertyChangeListener(slider);
  installDefaults(slider);
  installListeners(slider);
  installKeyboardActions(slider);
  scrollTimer = new Timer(100, scrollListener);
  scrollTimer.setInitialDelay(300);
  insetCache = slider.getInsets();
  leftToRightCache = slider.getComponentOrientation().isLeftToRight();
  focusRect = new Rectangle();
  focusInsets = new Insets(0, 0, 0, 0);
  contentRect = new Rectangle();
  labelRect = new Rectangle();
  tickRect = new Rectangle();
  trackRect = new Rectangle();
  thumbRect = new Rectangle();
  calculateGeometry(); // This figures out where the labels, ticks,
  // track, and thumb are.
}

代码示例来源:origin: org.java.net.substance/substance

this.tickRect.width = (this.slider.getPaintTicks()) ? this
    .getTickLength() : 0;
if (this.slider.getComponentOrientation().isLeftToRight()) {
  this.tickRect.x = this.trackRect.x + this.trackRect.width;
} else {
  this.tickRect.y -= 3;
} else {
  if (this.slider.getComponentOrientation().isLeftToRight()) {
    this.tickRect.x -= 2;
  } else {

代码示例来源:origin: com.github.insubstantial/substance

this.tickRect.width = (this.slider.getPaintTicks()) ? this
    .getTickLength() : 0;
if (this.slider.getComponentOrientation().isLeftToRight()) {
  this.tickRect.x = this.trackRect.x + this.trackRect.width;
} else {
  this.tickRect.y -= 3;
} else {
  if (this.slider.getComponentOrientation().isLeftToRight()) {
    this.tickRect.x -= 2;
  } else {

代码示例来源:origin: com.synaptix/SynaptixSwing

protected void calculateTickRect() {
  if (slider.getOrientation() == JSlider.HORIZONTAL) {
    tickRect.x = trackRect.x;
    tickRect.y = trackRect.y + trackRect.height;
    tickRect.width = trackRect.width;
    tickRect.height = (slider.getPaintTicks()) ? getTickLength() : 0;
  } else {
    tickRect.width = (slider.getPaintTicks()) ? getTickLength() : 0;
    if (slider.getComponentOrientation().isLeftToRight()) {
      tickRect.x = trackRect.x + trackRect.width;
    } else {
      tickRect.x = trackRect.x - tickRect.width;
    }
    tickRect.y = trackRect.y;
    tickRect.height = trackRect.height;
  }
}

代码示例来源:origin: com.synaptix/SynaptixSwing

protected void calculateTickRect() {
  if (slider.getOrientation() == JSlider.HORIZONTAL) {
    tickRect.x = trackRect.x;
    tickRect.y = trackRect.y + trackRect.height;
    tickRect.width = trackRect.width;
    tickRect.height = (slider.getPaintTicks()) ? getTickLength() : 0;
  } else {
    tickRect.width = (slider.getPaintTicks()) ? getTickLength() : 0;
    if (slider.getComponentOrientation().isLeftToRight()) {
      tickRect.x = trackRect.x + trackRect.width;
    } else {
      tickRect.x = trackRect.x - tickRect.width;
    }
    tickRect.y = trackRect.y;
    tickRect.height = trackRect.height;
  }
}

相关文章

JSlider类方法