Java Code Examples for org.jdesktop.swingx.JXTaskPane#getWidth()

The following examples show how to use org.jdesktop.swingx.JXTaskPane#getWidth() . These examples are extracted from open source projects. 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 Project: FlatLaf   File: FlatTaskPaneUI.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void paintTitleBackground( JXTaskPane group, Graphics g ) {
	int width = group.getWidth();
	int height = getTitleHeight( group ) ;
	float arc = UIScale.scale( (float) roundHeight );
	float lineWidth = UIScale.scale( 1f );

	// paint background
	g.setColor( group.isSpecial() ? specialTitleBackground : titleBackgroundGradientStart );
	((Graphics2D)g).fill( FlatUIUtils.createRoundRectanglePath( lineWidth, lineWidth,
		width - (lineWidth * 2), height - (lineWidth * 2), arc - lineWidth, arc - lineWidth, 0, 0 ) );

	// paint border
	if( borderColor != null ) {
		g.setColor( borderColor );
		((Graphics2D)g).fill( FlatUIUtils.createRoundRectangle( 0, 0, width, height, lineWidth, arc, arc, 0, 0 ) );
	}
}
 
Example 2
Source Project: darklaf   File: DarkTaskPaneUI.java    License: MIT License 5 votes vote down vote up
@Override
protected void paintTitleBackground(final JXTaskPane group, final Graphics g2) {
    Graphics2D g = (Graphics2D) g2;
    int w = group.getWidth();
    int h = group.getHeight();
    if (group.isSpecial()) {
        g.setColor(specialTitleBackground);
    } else {
        g.setColor(titleBackgroundGradientStart);
    }
    if (isCollapsed()) {
        PaintUtil.fillRoundRect(g, 0, 0, w, h, getRoundHeight());
        g.setColor(borderColor);
        PaintUtil.paintLineBorder(g, 0, 0, w, h, getRoundHeight());
    } else {
        Rectangle clip = g.getClip().getBounds();
        g.setClip(0, 0, w, h / 2 + 1);

        PaintUtil.fillRoundRect(g, 0, 0, w, h, getRoundHeight());
        g.setClip(0, h / 2, w, h / 2);
        g.fillRect(0, 0, w, h);

        g.setColor(borderColor);
        g.setClip(0, 0, w, h / 2);
        PaintUtil.paintLineBorder(g, 0, 0, w, h, getRoundHeight());

        g.setClip(0, h / 2, w, h / 2);
        PaintUtil.drawRect(g, 0, 0, w, h, 1);
        g.setClip(clip);
    }
}
 
Example 3
Source Project: FlatLaf   File: FlatTaskPaneUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void paintChevronControls( JXTaskPane group, Graphics g, int x, int y, int width, int height ) {
	Graphics2D g2 = (Graphics2D) g;

	// scale chevron size
	float cw = scale( 6f );
	float ch = scale( 3f );

	// create arrow shape
	int direction = group.isCollapsed() ? SwingConstants.SOUTH : SwingConstants.NORTH;
	Shape arrowShape = FlatArrowButton.createArrowShape( direction, true, cw, ch );

	// fix position of controls
	x = group.getComponentOrientation().isLeftToRight() ? (group.getWidth() - width - y) : y;

	// compute chevron position
	int cx = (int) (x + width / 2 - cw / 2);
	int cy = (int) (y + (height / 2 - ch));
	float offset = ch + UIScale.scale( 1f );

	// set stroke with scaled width
	g2.setStroke( new BasicStroke( scale( 1f ) ) );

	// paint
	g2.translate( cx, cy );
	g2.draw( arrowShape );
	g2.translate( 0, offset );
	g2.draw( arrowShape );
	g2.translate( -cx, -(cy + offset) );
}
 
Example 4
Source Project: FlatLaf   File: FlatTaskPaneUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void paintTitle( JXTaskPane group, Graphics g, Color textColor,
	int x, int y, int width, int height )
{
	// scale title position
	int titleX = UIScale.scale( 3 );
	int titleWidth = group.getWidth() - getTitleHeight(group) - titleX;
	if( !group.getComponentOrientation().isLeftToRight() ) {
		// right-to-left
		titleX = group.getWidth() - titleX - titleWidth;
	}

	super.paintTitle( group, g, textColor, titleX, y, titleWidth, height );
}