Java Code Examples for java.awt.Adjustable#HORIZONTAL

The following examples show how to use java.awt.Adjustable#HORIZONTAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScrollPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int getScrollDirection() {
    int sp = (orientation == Adjustable.HORIZONTAL)
            ? (int) getScrollPosition().getX()
            : (int) getScrollPosition().getY();
    Point pnt = SwingUtilities.convertPoint(comp, x, y, ((Container) getSource()).getComponents()[0]);
    int cp = (orientation == Adjustable.HORIZONTAL)
            ? pnt.x
            : pnt.y;
    int sl = (orientation == Adjustable.HORIZONTAL)
            ? (int) getViewportSize().getWidth()
            : (int) getViewportSize().getHeight();
    int cl = (orientation == Adjustable.HORIZONTAL)
            ? width
            : height;
    if (cp <= sp) {
        return ScrollAdjuster.DECREASE_SCROLL_DIRECTION;
    } else if ((cp + cl) > (sp + sl)
            && cp > sp) {
        return ScrollAdjuster.INCREASE_SCROLL_DIRECTION;
    } else {
        return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
    }
}
 
Example 2
Source File: ScrollBarUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
	int x = (int) trackBounds.getX();
	int y = (int) trackBounds.getY();
	int w = (int) trackBounds.getWidth();
	int h = (int) trackBounds.getHeight();

	g.setColor(Colors.SCROLLBAR_TRACK_BACKGROUND);
	g.fillRect(x - 1, y - 1, w + 2, h + 2);

	g.setColor(Colors.SCROLLBAR_TRACK_BORDER);
	if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
		g.drawLine(x, y, x + w, y);
	} else {
		g.drawLine(x, y, x, y + h);
	}
}
 
Example 3
Source File: ScrollBarUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
	int x = (int) thumbBounds.getX();
	int y = (int) thumbBounds.getY();
	int w = (int) thumbBounds.getWidth();
	int h = (int) thumbBounds.getHeight();

	if (c.isEnabled() && w > 0 && h > 0) {
		if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
			h -= 1;
			y++;
			drawHorizThumb(g, x, y, w, h);
		} else {
			w -= 1;
			x++;
			drawVertThumb(g, x, y, w, h);
		}
	}
}
 
Example 4
Source File: KeyboardJSliderScrollDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static int getButton(int direction, int orientation) {
    if (direction == ScrollAdjuster.DECREASE_SCROLL_DIRECTION) {
        return (orientation == Adjustable.HORIZONTAL) ? KeyEvent.VK_LEFT : KeyEvent.VK_DOWN;
    } else {
        return (orientation == Adjustable.HORIZONTAL) ? KeyEvent.VK_RIGHT : KeyEvent.VK_UP;
    }
}
 
Example 5
Source File: ScrollPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tells if a scrollbar is visible.
 *
 * @param orientation {@code Adjustable.HORIZONTAL} or
 * {@code Adjustable.VERTICAL}
 * @return trus if the bar is visible.
 */
public boolean isScrollbarVisible(int orientation) {
    if (orientation == Adjustable.HORIZONTAL) {
        return getViewportSize().getHeight() < getHeight() - getHScrollbarHeight();
    } else if (orientation == Adjustable.VERTICAL) {
        return getViewportSize().getWidth() < getWidth() - getVScrollbarWidth();
    } else {
        return false;
    }
}
 
Example 6
Source File: ScrollBarUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected JButton createDecreaseButton(int orientation) {
	if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
		this.decreaseButton = new GenericArrowButton(orientation, this.scrollbar.getHeight(), SCROLLBAR_WIDTH - 1);
	} else {
		this.decreaseButton = new GenericArrowButton(orientation, SCROLLBAR_WIDTH - 1, this.scrollbar.getWidth());
	}
	return this.decreaseButton;
}
 
Example 7
Source File: ScrollBarUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected JButton createIncreaseButton(int orientation) {
	if (this.scrollbar.getOrientation() == Adjustable.HORIZONTAL) {
		this.increaseButton = new GenericArrowButton(orientation, this.scrollbar.getHeight(), SCROLLBAR_WIDTH - 1);
	} else {
		this.increaseButton = new GenericArrowButton(orientation, SCROLLBAR_WIDTH - 1, this.scrollbar.getWidth());
	}
	return this.increaseButton;
}
 
Example 8
Source File: AbstractScrollDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private Point increasePoint(ComponentOperator oper, Point pnt, ScrollAdjuster adj, int direction) {
    return ((adj.getScrollOrientation() == Adjustable.HORIZONTAL)
            ? new Point(pnt.x + ((direction == 1) ? 1 : -1) * getDragAndDropStepLength(oper), pnt.y)
            : new Point(pnt.x, pnt.y + ((direction == 1) ? 1 : -1) * getDragAndDropStepLength(oper)));
}
 
Example 9
Source File: ScrollPaneDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int position(ComponentOperator oper, int orientation) {
    return (orientation == Adjustable.HORIZONTAL)
            ? ((ScrollPaneOperator) oper).getScrollPosition().x
            : ((ScrollPaneOperator) oper).getScrollPosition().y;
}
 
Example 10
Source File: SampleAnalysisWorkflowManagerIDTIMS.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
@Override
public void adjustmentValueChanged(AdjustmentEvent evt) {
    Adjustable source = evt.getAdjustable();

    // getValueIsAdjusting() returns true if the user is currently
    // dragging the scrollbar's knob and has not picked a final value
    if (evt.getValueIsAdjusting()) {
        // The user is dragging the knob
        return;
    } else {
        ((javax.swing.JScrollBar) source).getParent().repaint();
    }

    // Determine which scrollbar fired the event
    int orient = source.getOrientation();
    if (orient == Adjustable.HORIZONTAL) {
        // Event from horizontal scrollbar
    } else {
        // Event from vertical scrollbar
    }

    // Determine the type of event
    int type = evt.getAdjustmentType();
    switch (type) {
        case AdjustmentEvent.UNIT_INCREMENT:
            // Scrollbar was increased by one unit
            break;
        case AdjustmentEvent.UNIT_DECREMENT:
            // Scrollbar was decreased by one unit
            break;
        case AdjustmentEvent.BLOCK_INCREMENT:
            // Scrollbar was increased by one block
            break;
        case AdjustmentEvent.BLOCK_DECREMENT:
            // Scrollbar was decreased by one block
            break;
        case AdjustmentEvent.TRACK:
            // The knob on the scrollbar was dragged
            break;
    }

    // Get current value
    //int value = evt.getValue();
}
 
Example 11
Source File: SampleAnalysisWorkflowManagerLAICPMS.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
public void adjustmentValueChanged(AdjustmentEvent evt) {
    Adjustable source = evt.getAdjustable();

    // getValueIsAdjusting() returns true if the user is currently
    // dragging the scrollbar's knob and has not picked a final value
    if (evt.getValueIsAdjusting()) {
        // The user is dragging the knob
        return;
    } else {
        ((javax.swing.JScrollBar) source).getParent().repaint();
    }

    // Determine which scrollbar fired the event
    int orient = source.getOrientation();
    if (orient == Adjustable.HORIZONTAL) {
        // Event from horizontal scrollbar
    } else {
        // Event from vertical scrollbar
    }

    // Determine the type of event
    int type = evt.getAdjustmentType();
    switch (type) {
        case AdjustmentEvent.UNIT_INCREMENT:
            // Scrollbar was increased by one unit
            break;
        case AdjustmentEvent.UNIT_DECREMENT:
            // Scrollbar was decreased by one unit
            break;
        case AdjustmentEvent.BLOCK_INCREMENT:
            // Scrollbar was increased by one block
            break;
        case AdjustmentEvent.BLOCK_DECREMENT:
            // Scrollbar was decreased by one block
            break;
        case AdjustmentEvent.TRACK:
            // The knob on the scrollbar was dragged
            break;
    }

    // Get current value
    //int value = evt.getValue();
}
 
Example 12
Source File: HNav.java    From pdfxtk with Apache License 2.0 votes vote down vote up
public int  getOrientation()        {return Adjustable.HORIZONTAL;}