ch.randelshofer.quaqua.QuaquaToolBarSeparatorUI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Quaqua Show documentation
Show all versions of Quaqua Show documentation
A Mavenisation of the Quaqua Mac OSX Swing Look and Feel (Java library)
Quaqua Look and Feel (C) 2003-2010, Werner Randelshofer.
Mavenisation by Matt Gumbley, DevZendo.org - for problems with
Mavenisation, see Matt; for issues with Quaqua, see the Quaqua home page.
For full license details, see http://randelshofer.ch/quaqua/license.html
The newest version!
/*
* @(#)QuaquaToolBarSeparatorUI.java 1.2 2006-06-16
*
* Copyright (c) 2004-2010 Werner Randelshofer, Immensee, Switzerland.
* All rights reserved.
*
* You may not use, copy or modify this file, except in compliance with the
* license agreement you entered into with Werner Randelshofer.
* For details see accompanying license terms.
*/
package ch.randelshofer.quaqua;
import ch.randelshofer.quaqua.util.Debug;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
/**
* QuaquaToolBarSeparatorUI.
*
* @author Werner Randelshofer
* @version 1.2 2006-06-16 Fixed size values again.
*
1.1 2006-02-12 Fixed size values and drawing code.
*
1.0 28 March 2005 Created.
*/
public class QuaquaToolBarSeparatorUI extends BasicToolBarSeparatorUI {
private final static Stroke separatorStroke =
new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0,
new float[] {1f,2f}, 0f);
public static ComponentUI createUI( JComponent c ) {
return new QuaquaToolBarSeparatorUI();
}
protected void installDefaults( JSeparator s ) {
super.installDefaults(s);
s.setForeground(UIManager.getColor("ToolBarSeparator.foreground"));
}
public void paint( Graphics gr, JComponent c ) {
Graphics2D g = (Graphics2D) gr;
int width = c.getWidth();
int height = c.getHeight();
g.setColor(c.getForeground());
g.setStroke(separatorStroke);
JToolBar.Separator sep = (JToolBar.Separator) c;
if (sep.getOrientation() == JSeparator.HORIZONTAL) {
g.drawLine(2,height / 2, width - 3, height / 2);
} else {
g.drawLine(width / 2, 2, width / 2, height - 3);
}
Debug.paint(g, c, this);
}
public Dimension getMinimumSize( JComponent c ) {
// return new Dimension(11, 11);
JToolBar.Separator sep = (JToolBar.Separator) c;
if (sep.getOrientation() == JSeparator.HORIZONTAL) {
return new Dimension(1, 11);
} else {
return new Dimension(11, 1);
}
}
public Dimension getPreferredSize( JComponent c ) {
// return new Dimension(11, 11);
JToolBar.Separator sep = (JToolBar.Separator) c;
if (sep.getOrientation() == JSeparator.HORIZONTAL) {
return new Dimension(1, 11);
} else {
return new Dimension(11, 1);
}
}
public Dimension getMaximumSize( JComponent c ) {
JToolBar.Separator sep = (JToolBar.Separator) c;
if (sep.getOrientation() == JSeparator.HORIZONTAL) {
return new Dimension(Integer.MAX_VALUE, 11);
} else {
return new Dimension(11, Integer.MAX_VALUE);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy