ch.randelshofer.quaqua.QuaquaSplitPaneUI 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!
/*
* @(#)QuaquaSplitPaneUI.java
*
* Copyright (c) 2005-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 ch.randelshofer.quaqua.color.PaintableColor;
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
/**
* QuaquaSplitPaneUI.
*
* @author Werner Randelshofer
* @version $Id: QuaquaSplitPaneUI.java 361 2010-11-21 11:19:20Z wrandelshofer $
*/
public class QuaquaSplitPaneUI extends BasicSplitPaneUI {
/**
* Creates a new instance.
*/
public QuaquaSplitPaneUI() {
}
/**
* Creates a new BasicSplitPaneUI instance
*/
public static ComponentUI createUI(JComponent x) {
return new QuaquaSplitPaneUI();
}
/**
* Installs the UI defaults.
*/
protected void installDefaults() {
super.installDefaults();
QuaquaUtilities.installProperty(splitPane, "opaque", UIManager.get("SplitPane.opaque"));
//splitPane.setOpaque(QuaquaManager.getBoolean("SplitPane.opaque"));
/*
splitPane.setContinuousLayout(true);
setContinuousLayout(splitPane.isContinuousLayout());
*/
splitPane.setFocusable(UIManager.getBoolean("SplitPane.focusable"));
}
/**
* Creates the default divider.
*/
public BasicSplitPaneDivider createDefaultDivider() {
return new QuaquaSplitPaneDivider(this);
}
public void paint(Graphics gr, JComponent c) {
Graphics2D g = (Graphics2D) gr;
Object oldHints = QuaquaUtilities.beginGraphics(g);
if (c.isOpaque()) {
g.setPaint(PaintableColor.getPaint(c.getBackground(), c));
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
super.paint(gr, c);
Debug.paint(gr, c, this);
QuaquaUtilities.endGraphics((Graphics2D) g, oldHints);
}
/**
* Messaged after the JSplitPane the receiver is providing the look
* and feel for paints its children.
*/
public void finishedPaintingChildren(JSplitPane jc, Graphics g) {
if (jc == splitPane && getLastDragLocation() != -1 &&
!isContinuousLayout() && !draggingHW) {
Dimension size = splitPane.getSize();
g.setColor(UIManager.getColor("SplitPaneDivider.draggingColor"));
if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
g.fillRect(getLastDragLocation(), 0, dividerSize,
size.height);
} else {
g.fillRect(0, getLastDragLocation(), size.width,
dividerSize);
}
}
}
/**
* Returns the default non continuous layout divider, which is an
* instanceof Canvas that fills the background in dark gray.
*/
protected Component createDefaultNonContinuousLayoutDivider() {
return new Canvas() {
public void paint(Graphics g) {
if (!isContinuousLayout() && getLastDragLocation() != -1) {
Dimension size = splitPane.getSize();
g.setColor(UIManager.getColor("SplitPaneDivider.draggingColor"));
if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
g.fillRect(0, 0, dividerSize, size.height);
} else {
g.fillRect(0, 0, size.width, dividerSize);
}
}
}
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy