squareness-2.3.0/source/ 40755 0 0 0 10563076303 12242 5 ustar 0 0 squareness-2.3.0/source/net/ 40755 0 0 0 10563076303 13030 5 ustar 0 0 squareness-2.3.0/source/net/beeger/ 40755 0 0 0 10563076303 14261 5 ustar 0 0 squareness-2.3.0/source/net/beeger/squareness/ 40755 0 0 0 10563076303 16452 5 ustar 0 0 squareness-2.3.0/source/net/beeger/squareness/delegate/ 40755 0 0 0 10563076303 20224 5 ustar 0 0 squareness-2.3.0/source/net/beeger/squareness/icons/ 40755 0 0 0 10563076303 17565 5 ustar 0 0 squareness-2.3.0/source/net/beeger/squareness/theme/ 40755 0 0 0 10563076303 17554 5 ustar 0 0 squareness-2.3.0/source/net/beeger/squareness/util/ 40755 0 0 0 10563076303 17427 5 ustar 0 0 squareness-2.3.0/source/org/ 40755 0 0 0 10334223450 13022 5 ustar 0 0 squareness-2.3.0/source/org/jvnet/ 40755 0 0 0 10334223460 14151 5 ustar 0 0 squareness-2.3.0/source/org/jvnet/lafplugin/ 40755 0 0 0 10563076303 16140 5 ustar 0 0 squareness-2.3.0/build.xml 100644 0 0 4154 10563076303 12664 0 ustar 0 0
This class contains all the constants used in this Look And Feel.
*/ public final class SquarenessConstants { // // public interface // public static final String SCROLLBAR_THUMB_PRESSED_CLIENT_PROPERTY_KEY = "SquarenessScrollBarThumbPressed"; public static final String SCROLLBAR_TRACK_PRESSED_CLIENT_PROPERTY_KEY = "SquarenessScrollBarTrackPressed"; public static final String SCROLL_ARROW_LEFT_KEY = "scrollArrowLeft"; public static final String SCROLL_ARROW_RIGHT_KEY = "scrollArrowRight"; public static final String SCROLL_ARROW_UP_KEY = "scrollArrowUp"; public static final String SCROLL_ARROW_DOWN_KEY = "scrollArrowDown"; public static final String SPIN_UP_KEY = "spinUp"; public static final String SPIN_DOWN_KEY = "spinDown"; public static final String ROLLOVER_CLENT_PROPERTY_KEY = "SquarenessRollover"; public static final String CHECKED_FOR_JEDIT_ROLLOVER ="SquarenessCheckedJEDITROLLOVER"; private SquarenessConstants () { } } squareness-2.3.0/source/net/beeger/squareness/SquarenessLookAndFeel.java 100644 0 0 56766 10563076303 23653 0 ustar 0 0 /* Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of 'Robert F. Beeger' nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other skins from the Squareness series. */ package net.beeger.squareness; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import java.util.Iterator; import java.util.Map; import javax.swing.LookAndFeel; import javax.swing.UIDefaults; import javax.swing.UIManager; import javax.swing.plaf.BorderUIResource; import javax.swing.plaf.metal.MetalLookAndFeel; import net.beeger.squareness.theme.DefaultSquarenessTheme; import net.beeger.squareness.theme.PropertiesSquarenessTheme; import net.beeger.squareness.theme.SquarenessTheme; import net.beeger.squareness.util.SquarenessBorderFactory; import net.beeger.squareness.util.SquarenessIconFactory; import org.jvnet.lafplugin.ComponentPluginManager; /** *This is the core class of the Squareness Look And Feel.
*It sets up the colors, fonts, ui delegates as well as other resources and defaults * used by this look and feel.
*/ public class SquarenessLookAndFeel extends MetalLookAndFeel { public static void setCurrentSquarenessTheme(SquarenessTheme theme) { _currentSquarenessTheme = theme; MetalLookAndFeel.setCurrentTheme(theme); } public static SquarenessTheme getCurrentSquarenessTheme() { if (_currentSquarenessTheme == null) { loadThemePackageTheme(); } if (_currentSquarenessTheme == null) { setCurrentSquarenessTheme(new DefaultSquarenessTheme()); } return _currentSquarenessTheme; } public static void loadThemePackageTheme () { final InputStream themeSelectorStream = SquarenessLookAndFeel.class.getResourceAsStream("/themeselector.slfts"); if (themeSelectorStream != null) { Properties themeSelector = new Properties(); try { themeSelector.load(themeSelectorStream); String themeFileName = themeSelector.getProperty("currentTheme"); if (themeFileName != null && themeFileName.trim().length() > 0) { Properties theme = new Properties(); theme.load(SquarenessLookAndFeel.class.getResourceAsStream("/" + themeFileName)); setCurrentSquarenessTheme(new PropertiesSquarenessTheme(theme)); } } catch (IOException e) { e.printStackTrace(); } catch (PropertiesSquarenessTheme.LoadException e) { e.printStackTrace(); } } } public SquarenessLookAndFeel () { } /** * Is the look and feel a native look and feel? * * @return true if the look and feel is a native look and feel, false otherwise */ public boolean isNativeLookAndFeel () { return false; } /** *Is this look and feel supported on the underlying plattform?
*Note: The Squareness look and feel is supported on any available plattform. So this method always * returns true.
* * @return true if the look and feel is supported on the underlying plattform, false otherwise. */ public boolean isSupportedLookAndFeel () { return true; } /** * Return the description of the look and feel. * * @return The description of the look and feel. */ public String getDescription () { return DESCRIPTION; } /** * Return the id of the look and feel. * * @return The id of the look and feel */ public String getID () { return ID; } /** * Return the name of the look and feel. * * @return The name of the look and feel. */ public String getName () { return NAME; } // // protected interface // public void initialize () { super.initialize(); _plugins.initializeAll(); } public void uninitialize() { super.uninitialize(); _plugins.uninitializeAll(); } /** * Initialize the uiClassID to BasicComponentUI mapping. * The JComponent classes define their own uiClassID constants * (see AbstractComponent.getUIClassID). This table must * map those constants to a BasicComponentUI class of the * appropriate type. * * @param table The table of defaults into which to put the defaults of this look and feel. * @see #getDefaults */ protected void initClassDefaults (UIDefaults table) { super.initClassDefaults(table); String packageName = "net.beeger.squareness.delegate."; table.put("ButtonUI", packageName + "SquarenessButtonUI"); table.put("RadioButtonUI", packageName + "SquarenessRadioButtonUI"); table.put("CheckBoxUI", packageName + "SquarenessCheckBoxUI"); table.put("ToolBarUI", packageName + "SquarenessToolBarUI"); table.put("ToggleButtonUI", packageName + "SquarenessToggleButtonUI"); table.put("ScrollBarUI", packageName + "SquarenessScrollBarUI"); table.put("TabbedPaneUI", packageName + "SquarenessTabbedPaneUI"); table.put("ComboBoxUI", packageName + "SquarenessComboBoxUI"); table.put("SliderUI", packageName + "SquarenessSliderUI"); table.put("InternalFrameUI", packageName + "SquarenessInternalFrameUI"); table.put("SpinnerUI", packageName + "SquarenessSpinnerUI"); table.put("RootPaneUI", packageName + "SquarenessRootPaneUI"); table.put("ProgressBarUI", "javax.swing.plaf.basic.BasicProgressBarUI"); table.put("SplitPaneUI", "javax.swing.plaf.basic.BasicSplitPaneUI"); } protected void initComponentDefaults (UIDefaults table) { setCurrentTheme(new DefaultSquarenessTheme()); super.initComponentDefaults(table); table.put(SquarenessConstants.SCROLL_ARROW_LEFT_KEY, new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getLeftIcon(); } }); table.put(SquarenessConstants.SCROLL_ARROW_RIGHT_KEY, new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getRightIcon(); } }); table.put(SquarenessConstants.SCROLL_ARROW_UP_KEY, new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getUpIcon(); } }); table.put(SquarenessConstants.SCROLL_ARROW_DOWN_KEY, new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getDownIcon(); } }); table.put(SquarenessConstants.SPIN_UP_KEY, new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getSpinUpIcon(); } }); table.put(SquarenessConstants.SPIN_DOWN_KEY, new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getSpinDownIcon(); } }); UIDefaults.LazyValue borderWithMargin = new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessBorderFactory.getControlBorderWithMargin(); } }; UIDefaults.LazyValue borderWithoutMargin = new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessBorderFactory.getControlBorderWithoutMargin(); } }; UIDefaults.LazyValue progressBarBorder = new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessBorderFactory.getProgressBarBorder(); } }; UIDefaults.LazyValue tableHeaderCellBorder = new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessBorderFactory.getTableHeaderCellBorder(); } }; table.put("Button.background", getCurrentSquarenessTheme().getNormalControlBackgroundColor()); table.put("Button.border", borderWithMargin); table.put("ToggleButton.background", getCurrentSquarenessTheme().getNormalControlBackgroundColor()); table.put("ToggleButton.border", borderWithMargin); table.put("RadioButton.icon", new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getRadioButtonIcon(); } }); table.put("CheckBox.icon", new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getCheckBoxIcon(); } }); UIDefaults.LazyValue emptyborder = new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0); } }; UIDefaults.LazyValue menuItemBorder = new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessBorderFactory.getMenuItemBorder(); } }; UIDefaults.LazyValue menuItemCheckIcon = new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getMenuItemCheckIcon(); } }; UIDefaults.LazyValue menuItemArrowIcon = new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getMenuItemArrowIcon(); } }; table.put("TextField.border", borderWithoutMargin); table.put("FormattedTextField.border", borderWithoutMargin); table.put("PasswordField.border", borderWithoutMargin); table.put("MenuBar.background", getCurrentSquarenessTheme().getWindowBackgroundColor()); table.put("MenuBar.border", emptyborder); table.put("Menu.background", null); table.put("Menu.border", menuItemBorder); table.put("Menu.borderPainted", Boolean.TRUE); table.put("Menu.selectionForeground", table.get("textHighlightText")); table.put("Menu.selectionBackground", table.get("textHighlight")); table.put("Menu.arrowIcon", new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getMenuArrowIcon(); } }); table.put("Menu.checkIcon", menuItemCheckIcon); table.put("MenuItem.background", null); table.put("MenuItem.border", menuItemBorder); table.put("MenuItem.borderPainted", Boolean.TRUE); table.put("MenuItem.selectionForeground", table.get("textHighlightText")); table.put("MenuItem.selectionBackground", table.get("textHighlight")); table.put("MenuItem.checkIcon", menuItemCheckIcon); table.put("RadioButtonMenuItem.background", null); table.put("RadioButtonMenuItem.border", menuItemBorder); table.put("RadioButtonMenuItem.borderPainted", Boolean.TRUE); table.put("RadioButtonMenuItem.selectionForeground", table.get("textHighlightText")); table.put("RadioButtonMenuItem.selectionBackground", table.get("textHighlight")); table.put("RadioButtonMenuItem.checkIcon", new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getRadioButtonMenuItemCheckIcon(); } }); table.put("RadioButtonMenuItem.arrowIcon", menuItemArrowIcon); table.put("CheckBoxMenuItem.background", null); table.put("CheckBoxMenuItem.border", menuItemBorder); table.put("CheckBoxMenuItem.borderPainted", Boolean.TRUE); table.put("CheckBoxMenuItem.selectionForeground", table.get("textHighlightText")); table.put("CheckBoxMenuItem.selectionBackground", table.get("textHighlight")); table.put("CheckBoxMenuItem.checkIcon", new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getCheckBoxMenuItemCheckIcon(); } }); table.put("CheckBoxMenuItem.arrowIcon", menuItemArrowIcon); table.put("Separator.foreground", getCurrentSquarenessTheme().getNormalBorderColor()); table.put("Separator.background", null); table.put("PopupMenu.border", new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessBorderFactory.getNonSpacingControlBorderWithoutMargin(); } }); UIDefaults.LazyValue frameBorder = new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessBorderFactory.getInternalFrameBorder(); } }; table.put("InternalFrame.border", frameBorder); table.put("InternalFrame.icon", null); table.put("InternalFrame.maximizeIcon", new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getMaximizeFrameIcon(); } }); table.put("InternalFrame.minimizeIcon", new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getMinimizeFrameIcon(); } }); table.put("InternalFrame.iconifyIcon", new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getIconifyFrameIcon(); } }); table.put("InternalFrame.closeIcon", new UIDefaults.LazyValue() { public Object createValue (UIDefaults table) { return SquarenessIconFactory.getCloseFrameIcon(); } }); table.put("RootPane.frameBorder", frameBorder); table.put("RootPane.plainDialogBorder", frameBorder); table.put("RootPane.informationDialogBorder", frameBorder); table.put("RootPane.errorDialogBorder", frameBorder); table.put("RootPane.colorChooserDialogBorder", frameBorder); table.put("RootPane.fileChooserDialogBorder", frameBorder); table.put("RootPane.questionDialogBorder", frameBorder); table.put("RootPane.warningDialogBorder", frameBorder); table.put("ScrollBar.thumb", getCurrentSquarenessTheme().getNormalControlBackgroundColor()); table.put("ScrollBar.background", getCurrentSquarenessTheme().getProgressBarBackgroundColor()); table.put("ScrollBar.width", new Integer(17)); table.put("ScrollPane.border", borderWithoutMargin); table.put("TableHeader.background", getCurrentSquarenessTheme().getNormalControlBackgroundColor()); table.put("ToolBar.border", emptyborder); table.put("ToolBar.background", getCurrentSquarenessTheme().getWindowBackgroundColor()); table.put("ComboBox.border", borderWithoutMargin); table.put("ComboBox.background", getCurrentSquarenessTheme().getTextInputBackgroundColor()); table.put("ComboBox.selectionBackground", table.get("textHighlight")); table.put("ComboBox.selectionForeground", table.get("textHighlightText")); table.put("ProgressBar.border", progressBarBorder); table.put("ProgressBar.cellLength", new Integer(1)); table.put("ProgressBar.cellSpacing", new Integer(1)); table.put("ProgressBar.selectionForeground", getCurrentSquarenessTheme().getTextColor()); table.put("ProgressBar.selectionBackground", getCurrentSquarenessTheme().getTextColor()); table.put("ProgressBar.foreground", getCurrentSquarenessTheme().getSelectedControlBackgroundColor()); table.put("ProgressBar.background", getCurrentSquarenessTheme().getProgressBarBackgroundColor()); table.put("SplitPane.highlight", getCurrentSquarenessTheme().getNormalBorderColor()); table.put("SplitPane.shadow", getCurrentSquarenessTheme().getNormalBorderColor()); table.put("SplitPane.darkShadow", getCurrentSquarenessTheme().getNormalBorderColor()); table.put("SplitPane.border", null); table.put("SplitPaneDivider.border", null); table.put("TabbedPane.selected", getCurrentSquarenessTheme().getWindowBackgroundColor()); table.put("TabbedPane.shadow", getCurrentSquarenessTheme().getNormalBorderColor().brighter().brighter()); table.put("TabbedPane.darkShadow", getCurrentSquarenessTheme().getNormalBorderColor()); table.put("TabbedPane.highlight", getCurrentSquarenessTheme().getWindowBackgroundColor().brighter().brighter()); table.put("TabbedPane.background", getCurrentSquarenessTheme().getWindowBackgroundColor()); table.put("TabbedPane.selected", null); table.put("Viewport.background", getCurrentSquarenessTheme().getWindowBackgroundColor()); table.put("Table.scrollPaneBorder", borderWithoutMargin); table.put("TableHeader.cellBorder", tableHeaderCellBorder); table.put("Panel.background", getCurrentSquarenessTheme().getWindowBackgroundColor()); table.put("Panel.foreground", getCurrentSquarenessTheme().getTextColor()); table.put("Tree.collapsedIcon", LookAndFeel.makeIcon(getClass(), "icons/treecollapsed.gif")); table.put("Tree.expandedIcon", LookAndFeel.makeIcon(getClass(), "icons/treeexpanded.gif")); table.put("Tree.openIcon", LookAndFeel.makeIcon(getClass(), "icons/folderopened.gif")); table.put("Tree.closedIcon", LookAndFeel.makeIcon(getClass(), "icons/folderclosed.gif")); table.put("Tree.leafIcon", LookAndFeel.makeIcon(getClass(), "icons/document.gif")); table.put("FileView.directoryIcon", LookAndFeel.makeIcon(getClass(), "icons/folderclosed.gif")); table.put("FileView.fileIcon", LookAndFeel.makeIcon(getClass(), "icons/document.gif")); table.put("FileView.computerIcon", LookAndFeel.makeIcon(getClass(), "icons/computer.gif")); table.put("FileView.hardDriveIcon", LookAndFeel.makeIcon(getClass(), "icons/hd.gif")); table.put("FileView.floppyDriveIcon", LookAndFeel.makeIcon(getClass(), "icons/floppy.gif")); table.put("FileChooser.detailsViewIcon", LookAndFeel.makeIcon(getClass(), "icons/detail.gif")); table.put("FileChooser.homeFolderIcon", LookAndFeel.makeIcon(getClass(), "icons/home.gif")); table.put("FileChooser.listViewIcon", LookAndFeel.makeIcon(getClass(), "icons/list.gif")); table.put("FileChooser.newFolderIcon", LookAndFeel.makeIcon(getClass(), "icons/folderclosed.gif")); table.put("FileChooser.upFolderIcon", LookAndFeel.makeIcon(getClass(), "icons/folderup.gif")); // table.put("Spinner.background",table.get(SquarenessConstants.NORMAL_CONTROL_COLOR_KEY)); // table.put("Spinner.foreground",table.get(SquarenessConstants.TEXT_TEXT_COLOR_KEY)); // table.put("Spinner.border", borderWithoutMargin); for (Iterator iterator = table.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); if (entry.getValue() instanceof String && ((String) entry.getValue()).startsWith("sounds/")) { entry.setValue("/javax/swing/plaf/metal/" + entry.getValue()); } } _plugins.processAllDefaultsEntries(UIManager.getDefaults(), _currentSquarenessTheme); } /** * Load the SystemColors into the defaults table. The keys * for SystemColor defaults are the same as the names of * the public fields in SystemColor. If the table is being * created on a native Windows platform we use the SystemColor * values, otherwise we create color objects whose values match * the defaults Windows95 colors. * * @param table The table of defaults into which to put the defaults of this look and feel. */ protected void initSystemColorDefaults (UIDefaults table) { table.put("desktop", getCurrentSquarenessTheme().getDesktopColor()); table.put("activeCaption", getCurrentSquarenessTheme().getWindowBackgroundColor()); table.put("activeCaptionText", getCurrentSquarenessTheme().getTextColor()); table.put("activeCaptionBorder", getCurrentSquarenessTheme().getNormalBorderColor()); table.put("inactiveCaption", getCurrentSquarenessTheme().getWindowBackgroundColor()); table.put("inactiveCaptionText", getCurrentSquarenessTheme().getDisabledBorderColor()); table.put("inactiveCaptionBorder", getCurrentSquarenessTheme().getInactiveWindowBorderColor()); table.put("window", getCurrentSquarenessTheme().getTextInputBackgroundColor()); table.put("windowBorder", getCurrentSquarenessTheme().getNormalBorderColor()); table.put("windowText", getCurrentSquarenessTheme().getTextColor()); table.put("menu", getCurrentSquarenessTheme().getProgressBarBackgroundColor()); table.put("menuText", getCurrentSquarenessTheme().getTextColor()); table.put("text", getCurrentSquarenessTheme().getTextInputBackgroundColor()); table.put("textText", getCurrentSquarenessTheme().getTextColor()); table.put("textHighlight", getCurrentSquarenessTheme().getSelectedControlBackgroundColor()); table.put("textHighlightText", getCurrentSquarenessTheme().getTextColor()); table.put("textInactiveText", getCurrentSquarenessTheme().getTextColor()); table.put("control", getCurrentSquarenessTheme().getWindowBackgroundColor()); table.put("controlText", getCurrentSquarenessTheme().getTextColor()); table.put("controlHighlight", getCurrentSquarenessTheme().getSelectedControlBackgroundColor()); table.put("controlLtHighlight", getCurrentSquarenessTheme().getSelectedControlBackgroundColor()); table.put("controlShadow", getCurrentSquarenessTheme().getSelectedControlBackgroundShadowColor()); table.put("controlDkShadow", getCurrentSquarenessTheme().getSelectedControlBackgroundShadowColor()); table.put("scrollbar", getCurrentSquarenessTheme().getProgressBarBackgroundColor()); table.put("info", getCurrentSquarenessTheme().getProgressBarBackgroundColor()); table.put("infoText", getCurrentSquarenessTheme().getTextColor()); } // // private interface private static final String PLUGIN_FILE_NAME = "META-INF/squareness-plugin.xml"; private static final ComponentPluginManager _plugins = new ComponentPluginManager(PLUGIN_FILE_NAME); private static final String DESCRIPTION = "Squareness Look And Feel"; private static final String ID = "Squareness"; private static final String NAME = "Squareness"; private static SquarenessTheme _currentSquarenessTheme; } squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessButtonUI.java 100644 0 0 11226 10563076303 24771 0 ustar 0 0 /* Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of 'Robert F. Beeger' nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other skins from the Squareness series. */ package net.beeger.squareness.delegate; import java.awt.Graphics; import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicButtonUI; import net.beeger.squareness.SquarenessConstants; import net.beeger.squareness.util.SquarenessBorderFactory; import net.beeger.squareness.util.SquarenessButtonPainter; import net.beeger.squareness.util.SquarenessListenerFactory; /** * The Squareness Button UI delegate. */ public class SquarenessButtonUI extends BasicButtonUI { /** * Create the UI delegate for the given component * * @param component The component for which to create the ui delegate * @return The created ui delegate */ public static ComponentUI createUI (JComponent component) { return _buttonUI; } /** * Install the UI delegate for the given component * * @param component The component for which to install the ui delegate. */ public void installUI (JComponent component) { component.putClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY, Boolean.FALSE); component.addMouseListener(SquarenessListenerFactory.getButtonRolloverMouseListener()); super.installUI(component); } /** * Uninstall the UI delegate * * @param component The component from which to uninstall the UI delegate. */ public void uninstallUI (JComponent component) { component.removeMouseListener(SquarenessListenerFactory.getButtonRolloverMouseListener()); super.uninstallUI(component); } /** * Paint the component. * * @param graphics The graphics resource used to paint the component * @param component The component to paint. */ public void paint (Graphics graphics, JComponent component) { if (!"yes".equals(component.getClientProperty(SquarenessConstants.CHECKED_FOR_JEDIT_ROLLOVER))) { component.putClientProperty(SquarenessConstants.CHECKED_FOR_JEDIT_ROLLOVER, "yes"); boolean jEditRolloverButton = false; Class currentClass = component.getClass(); String currentClassName = currentClass.getName(); while (!jEditRolloverButton && currentClass != null && !(currentClassName.startsWith("java.") || currentClassName.startsWith("javax."))) { if ("org.gjt.sp.jedit.gui.RolloverButton".equals(currentClass.getName())) { jEditRolloverButton = true; } else { currentClass = currentClass.getSuperclass(); } } if (jEditRolloverButton) { component.setBorder(SquarenessBorderFactory.getButtonRolloverBorder()); } } SquarenessButtonPainter.paintButton(graphics, (AbstractButton) component); super.paint(graphics, component); } /** * One instance handles all buttons. */ private static SquarenessButtonUI _buttonUI = new SquarenessButtonUI(); } squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessCheckBoxUI.java 100644 0 0 6307 10563076303 25170 0 ustar 0 0 /* Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of 'Robert F. Beeger' nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other skins from the Squareness series. */ package net.beeger.squareness.delegate; import javax.swing.JComponent; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicCheckBoxUI; import net.beeger.squareness.SquarenessConstants; import net.beeger.squareness.util.SquarenessListenerFactory; /** * The Squareness Check Box UI delegate. */ public class SquarenessCheckBoxUI extends BasicCheckBoxUI { /** * Create the UI delegate for the given component * * @param component The component for which to create the ui delegate * @return The created ui delegate */ public static ComponentUI createUI (JComponent component) { return _buttonUI; } /** * Install the UI delegate for the given component * * @param component The component for which to install the ui delegate. */ public void installUI (JComponent component) { component.putClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY, Boolean.FALSE); component.addMouseListener(SquarenessListenerFactory.getButtonRolloverMouseListener()); super.installUI(component); } /** * Uninstall the UI delegate. * * @param component The component from which to uninstall the UI delegate. */ public void uninstallUI (JComponent component) { component.removeMouseListener(SquarenessListenerFactory.getButtonRolloverMouseListener()); super.uninstallUI(component); } private static SquarenessCheckBoxUI _buttonUI = new SquarenessCheckBoxUI(); } squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessComboBoxUI.java 100644 0 0 5615 10563076303 25213 0 ustar 0 0 /* Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of 'Robert F. Beeger' nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other skins from the Squareness series. */ package net.beeger.squareness.delegate; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.UIDefaults; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicComboBoxUI; import net.beeger.squareness.SquarenessConstants; import net.beeger.squareness.util.SquarenessBorderFactory; /** * The Squareness Combo Box UI delegate. */ public class SquarenessComboBoxUI extends BasicComboBoxUI { /** * Create the UI delegate for the given component * * @param component The component for which to create the ui delegate * @return The created ui delegate */ public static ComponentUI createUI (JComponent component) { return new SquarenessComboBoxUI(); } /** * Create the arrow button for the combo box. * * @return The created arrow button. */ protected JButton createArrowButton () { UIDefaults defaults = UIManager.getDefaults(); JButton button = new JButton(defaults.getIcon(SquarenessConstants.SCROLL_ARROW_DOWN_KEY)); button.setBorder(SquarenessBorderFactory.getNonSpacingControlBorderWithMargin()); return button; } } squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessInternalFrameUI.java 100644 0 0 13566 10563076303 26256 0 ustar 0 0 /* Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of 'Robert F. Beeger' nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other skins from the Squareness series. */ package net.beeger.squareness.delegate; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; import javax.swing.JComponent; import javax.swing.JInternalFrame; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicInternalFrameUI; import net.beeger.squareness.util.SquarenessTitlePane; /** * The Squareness Internal Frame UI delegate. */ public class SquarenessInternalFrameUI extends BasicInternalFrameUI { /** * Create the UI delegate for the given component * * @param component The component for which to create the ui delegate * @return The created ui delegate */ public static ComponentUI createUI (JComponent component) { return new SquarenessInternalFrameUI((JInternalFrame) component); } /** * Create the UI delegate. * * @param internalFrame The internal frame this delegate will be used for. */ public SquarenessInternalFrameUI (JInternalFrame internalFrame) { super(internalFrame); } /** * Create the title bar of the internal frame. * * @param internalFrame The internalframe for which to create the title bar. * @return The created title bar. */ protected JComponent createNorthPane (JInternalFrame internalFrame) { _titlePane = new SquarenessInternalFrameTitlePane(internalFrame); return _titlePane; } /** * The class for title bars of internal frames. */ protected static class SquarenessInternalFrameTitlePane extends SquarenessTitlePane { public SquarenessInternalFrameTitlePane (JInternalFrame frame) { _frame = frame; _frame.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange (PropertyChangeEvent evt) { update(); _frame.revalidate(); _frame.repaint(); } }); } public boolean isLeftToRight () { return _frame.getComponentOrientation().isLeftToRight(); } protected boolean isIconifiable () { return _frame.isIconifiable(); } protected boolean isMaximizable () { return _frame.isMaximizable(); } protected boolean isClosable () { return _frame.isClosable(); } protected void close () { if (isClosable()) { _frame.doDefaultCloseAction(); } } protected void iconify () { if (isIconifiable()) { if (!isIconified()) { try { _frame.setIcon(true); } catch (PropertyVetoException e1) { } } else { try { _frame.setIcon(false); } catch (PropertyVetoException e1) { } } } } protected void maximize () { if (isMaximizable()) { if (!isMaximized()) { try { _frame.setMaximum(true); } catch (PropertyVetoException e5) { } } else { try { _frame.setMaximum(false); } catch (PropertyVetoException e6) { } } } } protected void restore () { if (isMaximizable() && isMaximized()) { try { _frame.setMaximum(false); } catch (PropertyVetoException e4) { } } else if (isIconifiable() && isIconified()) { try { _frame.setIcon(false); } catch (PropertyVetoException e4) { } } } protected boolean isMaximized () { return _frame.isMaximum(); } protected boolean isIconified () { return _frame.isIcon(); } protected String getTitle () { return _frame.getTitle(); } private JInternalFrame _frame; } private SquarenessInternalFrameTitlePane _titlePane; } squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessRadioButtonUI.java 100644 0 0 6365 10563076303 25740 0 ustar 0 0 /* Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of 'Robert F. Beeger' nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other skins from the Squareness series. */ package net.beeger.squareness.delegate; import javax.swing.JComponent; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicRadioButtonUI; import net.beeger.squareness.SquarenessConstants; import net.beeger.squareness.util.SquarenessListenerFactory; /** * The Squareness radio button UI delegate. */ public class SquarenessRadioButtonUI extends BasicRadioButtonUI { /** * Create the UI delegate for the given component * * @param component The component for which to create the ui delegate * @return The created ui delegate */ public static ComponentUI createUI (JComponent component) { return _buttonUI; } /** * Install the UI delegate for the given component * * @param component The component for which to install the ui delegate. */ public void installUI (JComponent component) { component.putClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY, Boolean.FALSE); component.addMouseListener(SquarenessListenerFactory.getButtonRolloverMouseListener()); super.installUI(component); } /** * Uninstall the UI component from the given component. * * @param component The component to uninstall the UI delegate from. */ public void uninstallUI (JComponent component) { component.removeMouseListener(SquarenessListenerFactory.getButtonRolloverMouseListener()); super.uninstallUI(component); } private static final SquarenessRadioButtonUI _buttonUI = new SquarenessRadioButtonUI(); } squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessRootPaneUI.java 100644 0 0 115617 10563076303 25276 0 ustar 0 0 /* Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of 'Robert F. Beeger' nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other skins from the Squareness series. */ package net.beeger.squareness.delegate; import java.awt.Component; import java.awt.Container; import java.awt.Cursor; import java.awt.Dialog; import java.awt.Dimension; import java.awt.Frame; import java.awt.Insets; import java.awt.LayoutManager; import java.awt.LayoutManager2; import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.Window; import java.awt.Graphics; import java.awt.Color; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.JComponent; import javax.swing.JLayeredPane; import javax.swing.JRootPane; import javax.swing.LookAndFeel; import javax.swing.SwingUtilities; import javax.swing.JDialog; import javax.swing.event.MouseInputListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicRootPaneUI; import net.beeger.squareness.util.SquarenessTitlePane; import net.beeger.squareness.SquarenessLookAndFeel; /** *The bigger part of this ui delegate is a copy of MetalRootPaneUI, which is unfortunately not * suited for subclassing.
*The only Squareness-Part of this is the SquarenessFrameTitlePane which is defined as an inner class of this * one and is used in createTitlePane. Had the original authors of MetalRootPaneUI thought of making that method * protected this ui delegate would look nice and crisp.
*/ public class SquarenessRootPaneUI extends BasicRootPaneUI { public static ComponentUI createUI (JComponent c) { return new SquarenessRootPaneUI(); } /** * Keys to lookup borders in defaults table. */ private static final String[] borderKeys = new String[]{ null, "RootPane.frameBorder", "RootPane.plainDialogBorder", "RootPane.informationDialogBorder", "RootPane.errorDialogBorder", "RootPane.colorChooserDialogBorder", "RootPane.fileChooserDialogBorder", "RootPane.questionDialogBorder", "RootPane.warningDialogBorder" }; /** * The amount of space (in pixels) that the cursor is changed on. */ private static final int CORNER_DRAG_WIDTH = 16; /** * Region from edges that dragging is active from. */ private static final int BORDER_DRAG_THICKNESS = 5; /** * Window theJRootPane
is in.
*/
private Window _window;
/**
* JComponent
providing _window decorations. This will be
* null if not providing _window decorations.
*/
private JComponent _titlePane;
/**
* MouseInputListener
that is added to the parent
* Window
the JRootPane
is contained in.
*/
private MouseInputListener _mouseInputListener;
/**
* The LayoutManager
that is set on the
* JRootPane
.
*/
private LayoutManager _layoutManager;
/**
* LayoutManager
of the JRootPane
before we
* replaced it.
*/
private LayoutManager _savedOldLayout;
/**
* JRootPane
providing the look and feel for.
*/
private JRootPane _root;
/**
* Cursor
used to track the cursor set by the user.
* This is initially Cursor.DEFAULT_CURSOR
.
*/
private Cursor _lastCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
/**
* Invokes supers implementation of installUI
to install
* the necessary state onto the passed in JRootPane
* to render the metal look and feel implementation of
* RootPaneUI
. If
* the windowDecorationStyle
property of the
* JRootPane
is other than JRootPane.NONE
,
* this will add a custom Component
to render the widgets to
* JRootPane
, as well as installing a custom
* Border
and LayoutManager
on the
* JRootPane
.
*
* @param c the JRootPane to install state onto
*/
public void installUI (JComponent c)
{
super.installUI(c);
_root = (JRootPane) c;
int style = _root.getWindowDecorationStyle();
if (style != JRootPane.NONE)
{
installClientDecorations(_root);
}
}
/**
* Invokes supers implementation to uninstall any of its state. This will
* also reset the LayoutManager
of the JRootPane
.
* If a Component
has been added to the JRootPane
* to render the _window decoration style, this method will remove it.
* Similarly, this will revert the Border and LayoutManager of the
* JRootPane
to what it was before installUI
* was invoked.
*
* @param c the JRootPane to uninstall state from
*/
public void uninstallUI (JComponent c)
{
super.uninstallUI(c);
uninstallClientDecorations(_root);
_layoutManager = null;
_mouseInputListener = null;
_root = null;
}
/**
* Installs the appropriate Border
onto the
* JRootPane
.
*/
void installBorder (JRootPane root)
{
int style = root.getWindowDecorationStyle();
if (style == JRootPane.NONE)
{
LookAndFeel.uninstallBorder(root);
}
else
{
LookAndFeel.installBorder(root, borderKeys[style]);
}
}
/**
* Removes any border that may have been installed.
*/
private void uninstallBorder (JRootPane root)
{
LookAndFeel.uninstallBorder(root);
}
/**
* Installs the necessary Listeners on the parent Window
,
* if there is one.
*
* This takes the parent so that cleanup can be done from
* removeNotify
, at which point the parent hasn't been
* reset yet.
*
* @param parent The parent of the JRootPane
*/
private void installWindowListeners (JRootPane root, Component parent)
{
if (parent instanceof Window)
{
_window = (Window) parent;
}
else
{
_window = SwingUtilities.getWindowAncestor(parent);
}
if (_window != null)
{
if (_mouseInputListener == null)
{
_mouseInputListener = createWindowMouseInputListener();
}
_window.addMouseListener(_mouseInputListener);
_window.addMouseMotionListener(_mouseInputListener);
}
}
/**
* Uninstalls the necessary Listeners on the Window
the
* Listeners were last installed on.
*/
private void uninstallWindowListeners ()
{
if (_window != null)
{
_window.removeMouseListener(_mouseInputListener);
_window.removeMouseMotionListener(_mouseInputListener);
}
}
/**
* Installs the appropriate LayoutManager on the JRootPane
* to render the _window decorations.
*/
private void installLayout (JRootPane root)
{
if (_layoutManager == null)
{
_layoutManager = createLayoutManager();
}
_savedOldLayout = root.getLayout();
root.setLayout(_layoutManager);
}
/**
* Uninstalls the previously installed LayoutManager
.
*/
private void uninstallLayout (JRootPane root)
{
if (_savedOldLayout != null)
{
root.setLayout(_savedOldLayout);
_savedOldLayout = null;
}
}
/**
* Installs the necessary state onto the JRootPane to render client
* decorations. This is ONLY invoked if the JRootPane
* has a decoration style other than JRootPane.NONE
.
*/
private void installClientDecorations (JRootPane root)
{
installBorder(root);
JComponent titlePane = createTitlePane(root);
setTitlePane(root, titlePane);
installWindowListeners(root, root.getParent());
installLayout(root);
if (_window != null)
{
root.revalidate();
root.repaint();
}
}
/**
* Uninstalls any state that installClientDecorations
has
* installed.
*
* NOTE: This may be called if you haven't installed client decorations
* yet (ie before installClientDecorations
has been invoked).
*/
private void uninstallClientDecorations (JRootPane root)
{
uninstallBorder(root);
uninstallWindowListeners();
setTitlePane(root, null);
uninstallLayout(root);
// We have to revalidate/repaint _root if the style is JRootPane.NONE
// only. When we needs to call revalidate/repaint with other styles
// the installClientDecorations is always called after this method
// imediatly and it will cause the revalidate/repaint at the proper
// time.
int style = root.getWindowDecorationStyle();
if (style == JRootPane.NONE)
{
root.repaint();
root.revalidate();
}
// Reset the cursor, as we may have changed it to a resize cursor
if (_window != null)
{
_window.setCursor(Cursor.getPredefinedCursor
(Cursor.DEFAULT_CURSOR));
}
_window = null;
}
/**
* Returns the JComponent
to render the _window decoration
* style.
*/
private JComponent createTitlePane (JRootPane root)
{
return new SquarenessFrameTitlePane(root);
}
/**
* Returns a MouseListener
that will be added to the
* Window
containing the JRootPane
.
*/
private MouseInputListener createWindowMouseInputListener ()
{
return new MouseInputHandler();
}
/**
* Returns a LayoutManager
that will be set on the
* JRootPane
.
*/
private LayoutManager createLayoutManager ()
{
return new MetalRootLayout();
}
/**
* Sets the _window title pane -- the JComponent used to provide a plaf a
* way to override the native operating system's _window title pane with
* one whose look and feel are controlled by the plaf. The plaf creates
* and sets this value; the default is null, implying a native operating
* system _window title pane.
*/
private void setTitlePane (JRootPane root, JComponent titlePane)
{
JLayeredPane layeredPane = root.getLayeredPane();
JComponent oldTitlePane = getTitlePane();
if (oldTitlePane != null)
{
oldTitlePane.setVisible(false);
layeredPane.remove(oldTitlePane);
}
if (titlePane != null)
{
layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER);
titlePane.setVisible(true);
}
this._titlePane = titlePane;
}
/**
* Returns the JComponent
rendering the title pane. If this
* returns null, it implies there is no need to render _window decorations.
*
* @return the current _window title pane, or null
* @see #setTitlePane
*/
private JComponent getTitlePane ()
{
return _titlePane;
}
/**
* Returns the JRootPane
we're providing the look and
* feel for.
*/
private JRootPane getRootPane ()
{
return _root;
}
/**
* Invoked when a property changes. MetalRootPaneUI
is
* primarily interested in events originating from the
* JRootPane
it has been installed on identifying the
* property windowDecorationStyle
. If the
* windowDecorationStyle
has changed to a value other
* than JRootPane.NONE
, this will add a Component
* to the JRootPane
to render the _window decorations, as well
* as installing a Border
on the JRootPane
.
* On the other hand, if the windowDecorationStyle
has
* changed to JRootPane.NONE
, this will remove the
* Component
that has been added to the JRootPane
* as well resetting the Border to what it was before
* installUI
was invoked.
*
* @param e A PropertyChangeEvent object describing the event source
* and the property that has changed.
*/
public void propertyChange (PropertyChangeEvent e)
{
super.propertyChange(e);
String propertyName = e.getPropertyName();
if (propertyName == null)
{
return;
}
if (propertyName.equals("windowDecorationStyle"))
{
JRootPane root = (JRootPane) e.getSource();
int style = root.getWindowDecorationStyle();
// This is potentially more than needs to be done,
// but it rarely happens and makes the install/uninstall process
// simpler. MetalTitlePane also assumes it will be recreated if
// the decoration style changes.
uninstallClientDecorations(root);
if (style != JRootPane.NONE)
{
installClientDecorations(root);
}
}
else if (propertyName.equals("ancestor"))
{
uninstallWindowListeners();
if (((JRootPane) e.getSource()).getWindowDecorationStyle() !=
JRootPane.NONE)
{
installWindowListeners(_root, _root.getParent());
}
}
return;
}
/**
* A custom layout manager that is responsible for the layout of
* layeredPane, glassPane, menuBar and _titlePane, if one has been
* installed.
*/
// NOTE: Ideally this would extends JRootPane.RootLayout, but that
// would force this to be non-static.
private static class MetalRootLayout implements LayoutManager2
{
/**
* Returns the amount of space the layout would like to have.
*
* @param parent the Container for which this layout manager is being used
* @return a Dimension object containing the layout's preferred size
*/
public Dimension preferredLayoutSize (Container parent)
{
Dimension cpd, mbd, tpd;
int cpWidth = 0;
int cpHeight = 0;
int mbWidth = 0;
int mbHeight = 0;
int tpWidth = 0;
int tpHeight = 0;
Insets i = parent.getInsets();
JRootPane root = (JRootPane) parent;
if (root.getContentPane() != null)
{
cpd = root.getContentPane().getPreferredSize();
}
else
{
cpd = root.getSize();
}
if (cpd != null)
{
cpWidth = cpd.width;
cpHeight = cpd.height;
}
if (root.getJMenuBar() != null)
{
mbd = root.getJMenuBar().getPreferredSize();
if (mbd != null)
{
mbWidth = mbd.width;
mbHeight = mbd.height;
}
}
if (root.getWindowDecorationStyle() != JRootPane.NONE &&
(root.getUI() instanceof SquarenessRootPaneUI))
{
JComponent titlePane = ((SquarenessRootPaneUI) root.getUI()).
getTitlePane();
if (titlePane != null)
{
tpd = titlePane.getPreferredSize();
if (tpd != null)
{
tpWidth = tpd.width;
tpHeight = tpd.height;
}
}
}
return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right,
cpHeight + mbHeight + tpHeight + i.top + i.bottom);
}
/**
* Returns the minimum amount of space the layout needs.
*
* @param parent the Container for which this layout manager is being used
* @return a Dimension object containing the layout's minimum size
*/
public Dimension minimumLayoutSize (Container parent)
{
Dimension cpd, mbd, tpd;
int cpWidth = 0;
int cpHeight = 0;
int mbWidth = 0;
int mbHeight = 0;
int tpWidth = 0;
Insets i = parent.getInsets();
JRootPane root = (JRootPane) parent;
if (root.getContentPane() != null)
{
cpd = root.getContentPane().getMinimumSize();
}
else
{
cpd = root.getSize();
}
if (cpd != null)
{
cpWidth = cpd.width;
cpHeight = cpd.height;
}
if (root.getJMenuBar() != null)
{
mbd = root.getJMenuBar().getMinimumSize();
if (mbd != null)
{
mbWidth = mbd.width;
mbHeight = mbd.height;
}
}
if (root.getWindowDecorationStyle() != JRootPane.NONE &&
(root.getUI() instanceof SquarenessRootPaneUI))
{
JComponent titlePane = ((SquarenessRootPaneUI) root.getUI()).
getTitlePane();
if (titlePane != null)
{
tpd = titlePane.getMinimumSize();
if (tpd != null)
{
tpWidth = tpd.width;
}
}
}
return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right,
cpHeight + mbHeight + tpWidth + i.top + i.bottom);
}
/**
* Returns the maximum amount of space the layout can use.
*
* @param target parent the Container for which this layout manager is being used
* @return a Dimension object containing the layout's maximum size
*/
public Dimension maximumLayoutSize (Container target)
{
Dimension cpd, mbd, tpd;
int cpWidth = Integer.MAX_VALUE;
int cpHeight = Integer.MAX_VALUE;
int mbWidth = Integer.MAX_VALUE;
int mbHeight = Integer.MAX_VALUE;
int tpWidth = Integer.MAX_VALUE;
int tpHeight = Integer.MAX_VALUE;
Insets i = target.getInsets();
JRootPane root = (JRootPane) target;
if (root.getContentPane() != null)
{
cpd = root.getContentPane().getMaximumSize();
if (cpd != null)
{
cpWidth = cpd.width;
cpHeight = cpd.height;
}
}
if (root.getJMenuBar() != null)
{
mbd = root.getJMenuBar().getMaximumSize();
if (mbd != null)
{
mbWidth = mbd.width;
mbHeight = mbd.height;
}
}
if (root.getWindowDecorationStyle() != JRootPane.NONE &&
(root.getUI() instanceof SquarenessRootPaneUI))
{
JComponent titlePane = ((SquarenessRootPaneUI) root.getUI()).
getTitlePane();
if (titlePane != null)
{
tpd = titlePane.getMaximumSize();
if (tpd != null)
{
tpWidth = tpd.width;
tpHeight = tpd.height;
}
}
}
int maxHeight = Math.max(Math.max(cpHeight, mbHeight), tpHeight);
// Only overflows if 3 real non-MAX_VALUE heights, sum to > MAX_VALUE
// Only will happen if sums to more than 2 billion units. Not likely.
if (maxHeight != Integer.MAX_VALUE)
{
maxHeight = cpHeight + mbHeight + tpHeight + i.top + i.bottom;
}
int maxWidth = Math.max(Math.max(cpWidth, mbWidth), tpWidth);
// Similar overflow comment as above
if (maxWidth != Integer.MAX_VALUE)
{
maxWidth += i.left + i.right;
}
return new Dimension(maxWidth, maxHeight);
}
/**
* Instructs the layout manager to perform the layout for the specified
* container.
*
* @param parent the Container for which this layout manager is being used
*/
public void layoutContainer (Container parent)
{
JRootPane root = (JRootPane) parent;
Rectangle b = root.getBounds();
Insets i = root.getInsets();
int nextY = 0;
int w = b.width - i.right - i.left;
int h = b.height - i.top - i.bottom;
if (root.getLayeredPane() != null)
{
root.getLayeredPane().setBounds(i.left, i.top, w, h);
}
if (root.getGlassPane() != null)
{
root.getGlassPane().setBounds(i.left, i.top, w, h);
}
// Note: This is laying out the children in the layeredPane,
// technically, these are not our children.
if (root.getWindowDecorationStyle() != JRootPane.NONE &&
(root.getUI() instanceof SquarenessRootPaneUI))
{
JComponent titlePane = ((SquarenessRootPaneUI) root.getUI()).
getTitlePane();
if (titlePane != null)
{
Dimension tpd = titlePane.getPreferredSize();
if (tpd != null)
{
int tpHeight = tpd.height;
titlePane.setBounds(0, 0, w, tpHeight);
nextY += tpHeight;
}
}
}
if (root.getJMenuBar() != null)
{
Dimension mbd = root.getJMenuBar().getPreferredSize();
root.getJMenuBar().setBounds(0, nextY, w, mbd.height);
nextY += mbd.height;
}
if (root.getContentPane() != null)
{
root.getContentPane().setBounds(0, nextY, w,
h < nextY ? 0 : h - nextY);
}
}
public void addLayoutComponent (String name, Component comp)
{
}
public void removeLayoutComponent (Component comp)
{
}
public void addLayoutComponent (Component comp, Object constraints)
{
}
public float getLayoutAlignmentX (Container target)
{
return 0.0f;
}
public float getLayoutAlignmentY (Container target)
{
return 0.0f;
}
public void invalidateLayout (Container target)
{
}
}
/**
* Maps from positions to cursor type. Refer to calculateCorner and
* calculatePosition for details of this.
*/
private static final int[] cursorMapping = new int[]
{Cursor.NW_RESIZE_CURSOR, Cursor.NW_RESIZE_CURSOR, Cursor.N_RESIZE_CURSOR,
Cursor.NE_RESIZE_CURSOR, Cursor.NE_RESIZE_CURSOR,
Cursor.NW_RESIZE_CURSOR, 0, 0, 0, Cursor.NE_RESIZE_CURSOR,
Cursor.W_RESIZE_CURSOR, 0, 0, 0, Cursor.E_RESIZE_CURSOR,
Cursor.SW_RESIZE_CURSOR, 0, 0, 0, Cursor.SE_RESIZE_CURSOR,
Cursor.SW_RESIZE_CURSOR, Cursor.SW_RESIZE_CURSOR,
Cursor.S_RESIZE_CURSOR,
Cursor.SE_RESIZE_CURSOR, Cursor.SE_RESIZE_CURSOR
};
/**
* MouseInputHandler is responsible for handling resize/moving of
* the Window. It sets the cursor directly on the Window when then
* mouse moves over a hot spot.
*/
private class MouseInputHandler implements MouseInputListener
{
/**
* Set to true if the drag operation is moving the _window.
*/
private boolean isMovingWindow;
/**
* Used to determine the corner the resize is occuring from.
*/
private int dragCursor;
/**
* X location the mouse went down on for a drag operation.
*/
private int dragOffsetX;
/**
* Y location the mouse went down on for a drag operation.
*/
private int dragOffsetY;
/**
* Width of the _window when the drag started.
*/
private int dragWidth;
/**
* Height of the _window when the drag started.
*/
private int dragHeight;
public void mousePressed (MouseEvent ev)
{
JRootPane rootPane = getRootPane();
if (rootPane.getWindowDecorationStyle() == JRootPane.NONE)
{
return;
}
Point dragWindowOffset = ev.getPoint();
Window w = (Window) ev.getSource();
if (w != null)
{
w.toFront();
}
Point convertedDragWindowOffset = SwingUtilities.convertPoint(w, dragWindowOffset, getTitlePane());
Frame f = null;
Dialog d = null;
if (w instanceof Frame)
{
f = (Frame) w;
}
else if (w instanceof Dialog)
{
d = (Dialog) w;
}
int frameState = (f != null) ? f.getExtendedState() : 0;
if (getTitlePane() != null &&
getTitlePane().contains(convertedDragWindowOffset))
{
if ((f != null && ((frameState & Frame.MAXIMIZED_BOTH) == 0)
|| (d != null))
&& dragWindowOffset.y >= BORDER_DRAG_THICKNESS
&& dragWindowOffset.x >= BORDER_DRAG_THICKNESS
&& dragWindowOffset.x < w.getWidth()
- BORDER_DRAG_THICKNESS)
{
isMovingWindow = true;
dragOffsetX = dragWindowOffset.x;
dragOffsetY = dragWindowOffset.y;
}
}
else if (f != null && f.isResizable()
&& ((frameState & Frame.MAXIMIZED_BOTH) == 0)
|| (d != null && d.isResizable()))
{
dragOffsetX = dragWindowOffset.x;
dragOffsetY = dragWindowOffset.y;
dragWidth = w.getWidth();
dragHeight = w.getHeight();
dragCursor = getCursor(calculateCorner(w, dragWindowOffset.x, dragWindowOffset.y));
}
}
public void mouseReleased (MouseEvent ev)
{
if (dragCursor != 0 && _window != null && !_window.isValid())
{
// Some Window systems validate as you resize, others won't,
// thus the check for validity before repainting.
_window.validate();
getRootPane().repaint();
}
isMovingWindow = false;
dragCursor = 0;
}
public void mouseMoved (MouseEvent ev)
{
JRootPane root = getRootPane();
if (root.getWindowDecorationStyle() == JRootPane.NONE)
{
return;
}
Window w = (Window) ev.getSource();
Frame f = null;
Dialog d = null;
if (w instanceof Frame)
{
f = (Frame) w;
}
else if (w instanceof Dialog)
{
d = (Dialog) w;
}
// Update the cursor
int cursor = getCursor(calculateCorner(w, ev.getX(), ev.getY()));
if (cursor != 0 && ((f != null && (f.isResizable() &&
(f.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0))
|| (d != null && d.isResizable())))
{
w.setCursor(Cursor.getPredefinedCursor(cursor));
}
else
{
w.setCursor(_lastCursor);
}
}
private void adjust (Rectangle bounds, Dimension min, int deltaX,
int deltaY, int deltaWidth, int deltaHeight)
{
bounds.x += deltaX;
bounds.y += deltaY;
bounds.width += deltaWidth;
bounds.height += deltaHeight;
if (min != null)
{
if (bounds.width < min.width)
{
int correction = min.width - bounds.width;
if (deltaX != 0)
{
bounds.x -= correction;
}
bounds.width = min.width;
}
if (bounds.height < min.height)
{
int correction = min.height - bounds.height;
if (deltaY != 0)
{
bounds.y -= correction;
}
bounds.height = min.height;
}
}
}
public void mouseDragged (MouseEvent ev)
{
Window w = (Window) ev.getSource();
Point pt = ev.getPoint();
if (isMovingWindow)
{
Point windowPt = w.getLocationOnScreen();
windowPt.x += pt.x - dragOffsetX;
windowPt.y += pt.y - dragOffsetY;
w.setLocation(windowPt);
}
else if (dragCursor != 0)
{
Rectangle r = w.getBounds();
Rectangle startBounds = new Rectangle(r);
Dimension min = w.getMinimumSize();
switch (dragCursor)
{
case Cursor.E_RESIZE_CURSOR:
adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) -
r.width, 0);
break;
case Cursor.S_RESIZE_CURSOR:
adjust(r, min, 0, 0, 0, pt.y + (dragHeight - dragOffsetY) -
r.height);
break;
case Cursor.N_RESIZE_CURSOR:
adjust(r, min, 0, pt.y - dragOffsetY, 0,
-(pt.y - dragOffsetY));
break;
case Cursor.W_RESIZE_CURSOR:
adjust(r, min, pt.x - dragOffsetX, 0,
-(pt.x - dragOffsetX), 0);
break;
case Cursor.NE_RESIZE_CURSOR:
adjust(r, min, 0, pt.y - dragOffsetY,
pt.x + (dragWidth - dragOffsetX) - r.width,
-(pt.y - dragOffsetY));
break;
case Cursor.SE_RESIZE_CURSOR:
adjust(r, min, 0, 0,
pt.x + (dragWidth - dragOffsetX) - r.width,
pt.y + (dragHeight - dragOffsetY) -
r.height);
break;
case Cursor.NW_RESIZE_CURSOR:
adjust(r, min, pt.x - dragOffsetX,
pt.y - dragOffsetY,
-(pt.x - dragOffsetX),
-(pt.y - dragOffsetY));
break;
case Cursor.SW_RESIZE_CURSOR:
adjust(r, min, pt.x - dragOffsetX, 0,
-(pt.x - dragOffsetX),
pt.y + (dragHeight - dragOffsetY) - r.height);
break;
default:
break;
}
if (!r.equals(startBounds))
{
w.setBounds(r);
// Defer repaint/validate on mouseReleased unless dynamic
// layout is active.
if (Toolkit.getDefaultToolkit().isDynamicLayoutActive())
{
w.validate();
getRootPane().repaint();
}
}
}
}
public void mouseEntered (MouseEvent ev)
{
Window w = (Window) ev.getSource();
_lastCursor = w.getCursor();
mouseMoved(ev);
}
public void mouseExited (MouseEvent ev)
{
Window w = (Window) ev.getSource();
w.setCursor(_lastCursor);
}
public void mouseClicked (MouseEvent ev)
{
Window w = (Window) ev.getSource();
Frame f = null;
if (w instanceof Frame)
{
f = (Frame) w;
}
else
{
return;
}
Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane());
int state = f.getExtendedState();
if (getTitlePane() != null &&
getTitlePane().contains(convertedPoint))
{
if ((ev.getClickCount() % 2) == 0 &&
((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0))
{
if (f.isResizable())
{
if ((state & Frame.MAXIMIZED_BOTH) != 0)
{
f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH);
}
else
{
f.setExtendedState(state | Frame.MAXIMIZED_BOTH);
}
return;
}
}
}
}
/**
* Returns the corner that contains the point x
,
* y
, or -1 if the position doesn't match a corner.
*/
private int calculateCorner (Component c, int x, int y)
{
int xPosition = calculatePosition(x, c.getWidth());
int yPosition = calculatePosition(y, c.getHeight());
if (xPosition == -1 || yPosition == -1)
{
return -1;
}
return yPosition * 5 + xPosition;
}
/**
* Returns the Cursor to render for the specified corner. This returns
* 0 if the corner doesn't map to a valid Cursor
*/
private int getCursor (int corner)
{
if (corner == -1)
{
return 0;
}
return cursorMapping[corner];
}
/**
* Returns an integer indicating the position of spot
* in width
. The return value will be:
* 0 if < BORDER_DRAG_THICKNESS
* 1 if < CORNER_DRAG_WIDTH
* 2 if >= CORNER_DRAG_WIDTH && < width - BORDER_DRAG_THICKNESS
* 3 if >= width - CORNER_DRAG_WIDTH
* 4 if >= width - BORDER_DRAG_THICKNESS
* 5 otherwise
*/
private int calculatePosition (int spot, int width)
{
if (spot < BORDER_DRAG_THICKNESS)
{
return 0;
}
if (spot < CORNER_DRAG_WIDTH)
{
return 1;
}
if (spot >= (width - BORDER_DRAG_THICKNESS))
{
return 4;
}
if (spot >= (width - CORNER_DRAG_WIDTH))
{
return 3;
}
return 2;
}
}
/**
* The only Squareness part of this ui delegate - the one thing this is all about : the title pane.
*/
private static class SquarenessFrameTitlePane extends SquarenessTitlePane
{
public SquarenessFrameTitlePane (JRootPane rootPane)
{
_rootPane = rootPane;
}
public void addNotify ()
{
super.addNotify();
_window = SwingUtilities.getWindowAncestor(this);
_window.addPropertyChangeListener(new PropertyChangeListener()
{
public void propertyChange (PropertyChangeEvent evt)
{
update();
_window.repaint();
}
});
_rootPane.addPropertyChangeListener(new PropertyChangeListener()
{
public void propertyChange (PropertyChangeEvent evt)
{
update();
_window.repaint();
}
});
}
/**
* Calls the UI delegate's paint method, if the UI delegate
* is non-null
. We pass the delegate a copy of the
* Graphics
object to protect the rest of the
* paint code from irrevocable changes
* (for example, Graphics.translate
).
*
* If you override this in a subclass you should not make permanent
* changes to the passed in Graphics
. For example, you
* should not alter the clip Rectangle
or modify the
* transform. If you need to do these operations you may find it
* easier to create a new Graphics
from the passed in
* Graphics
and manipulate it. Further, if you do not
* invoker super's implementation you must honor the opaque property,
* that is
* if this component is opaque, you must completely fill in the background
* in a non-opaque color. If you do not honor the opaque property you
* will likely see visual artifacts.
*
* @param g the Graphics
object to protect
* @see #paint
* @see javax.swing.plaf.ComponentUI
*/
protected void paintComponent (Graphics g)
{
update();
Color oldColor = g.getColor();
g.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getWindowBackgroundColor());
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(oldColor);
}
public boolean isLeftToRight ()
{
return _window != null ? _window.getComponentOrientation().isLeftToRight() : true;
}
protected boolean isIconifiable ()
{
return isFrame();
}
protected boolean isMaximizable ()
{
return isFrame() && getFrame().isResizable();
}
protected boolean isClosable ()
{
return true;
}
protected void close ()
{
if (_window != null)
{
_window.dispatchEvent(new WindowEvent(_window, WindowEvent.WINDOW_CLOSING));
}
}
protected void iconify ()
{
if (isFrame())
{
Frame frame = getFrame();
frame.setExtendedState(getFrame().getExtendedState() | Frame.ICONIFIED);
}
}
protected void maximize ()
{
if (isFrame())
{
Frame frame = getFrame();
frame.setExtendedState(getFrame().getExtendedState() | Frame.MAXIMIZED_BOTH);
}
}
protected void restore ()
{
if (isFrame())
{
Frame frame = getFrame();
if (isIconified())
{
frame.setExtendedState(getFrame().getExtendedState() & ~Frame.ICONIFIED);
}
else
{
frame.setExtendedState(getFrame().getExtendedState() & ~Frame.MAXIMIZED_BOTH);
}
}
}
protected boolean isMaximized ()
{
return isFrame() && (getFrame().getExtendedState() & Frame.MAXIMIZED_BOTH) != 0;
}
protected boolean isIconified ()
{
return isFrame() && (getFrame().getExtendedState() & Frame.ICONIFIED) != 0;
}
protected String getTitle ()
{
String result = null;
if (isFrame())
{
result = getFrame().getTitle();
}
else if (isDialog())
{
result = getDialog().getTitle();
}
return result;
}
protected boolean isFrame ()
{
return _window instanceof Frame;
}
protected Frame getFrame ()
{
return (Frame) _window;
}
protected boolean isDialog ()
{
return _window instanceof JDialog;
}
protected JDialog getDialog ()
{
return (JDialog) _window;
}
private JRootPane _rootPane;
private Window _window;
}
} squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessScrollBarUI.java 100644 0 0 43324 10563076303 25405 0 ustar 0 0 /*
Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of 'Robert F. Beeger' nor the names of his contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other
skins from the Squareness series.
*/
package net.beeger.squareness.delegate;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JScrollBar;
import javax.swing.SwingConstants;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollBarUI;
import net.beeger.squareness.SquarenessConstants;
import net.beeger.squareness.SquarenessLookAndFeel;
import net.beeger.squareness.util.SquarenessBorderFactory;
/**
* The Squareness Scroll Bar UI delegate.
*/
public class SquarenessScrollBarUI extends BasicScrollBarUI
{
/**
* Create the ui delegate for the given component
*
* @param component The component for which to create the ui delegate
* @return The created ui delegate
*/
public static ComponentUI createUI (JComponent component)
{
return new SquarenessScrollBarUI();
}
/**
* Install this UI delegate for the given component.
*
* @param component The component to install this UI delegate for,.
*/
public void installUI (JComponent component)
{
component.putClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY, Boolean.FALSE);
component.putClientProperty(SquarenessConstants.SCROLLBAR_THUMB_PRESSED_CLIENT_PROPERTY_KEY, Boolean.FALSE);
component.putClientProperty(SquarenessConstants.SCROLLBAR_TRACK_PRESSED_CLIENT_PROPERTY_KEY, Boolean.FALSE);
_scrollBarMouseMotionListener = new ScrollBarMouseMotionListener();
_scrollBarMouseListener = new ScrollBarMouseListener();
component.addMouseMotionListener(_scrollBarMouseMotionListener);
component.addMouseListener(_scrollBarMouseListener);
super.installUI(component);
}
/**
* Uninstall this UI delegate from the given component.
*
* @param component The component to uninstall this UI delegate from.
*/
public void uninstallUI (JComponent component)
{
component.removeMouseMotionListener(_scrollBarMouseMotionListener);
component.removeMouseListener(_scrollBarMouseListener);
super.uninstallUI(component);
}
/**
* Paint the thumb of the scroll bar.
*
* @param graphics The graphics object used to paint the thumb.
* @param component The component (the scroll bar) to paint the thumb for.
* @param thumbBounds The bounds of the thumb.
*/
protected void paintThumb (Graphics graphics, JComponent component, Rectangle thumbBounds)
{
Color oldColor = graphics.getColor();
boolean isRollover = scrollbar.getClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY).equals(
Boolean.TRUE);
boolean isPressed = scrollbar.getClientProperty(SquarenessConstants.SCROLLBAR_THUMB_PRESSED_CLIENT_PROPERTY_KEY)
.equals(Boolean.TRUE);
Color thumbFillColor;
if (isRollover || isPressed)
{
thumbFillColor = SquarenessLookAndFeel.getCurrentSquarenessTheme().getSelectedControlBackgroundColor();
}
else
{
thumbFillColor = SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalControlBackgroundColor();
}
graphics.setColor(thumbFillColor);
graphics.fillRect(thumbBounds.x, thumbBounds.y, thumbBounds.width - 1, thumbBounds.height - 1);
if (isPressed)
{
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getSelectedControlBackgroundShadowColor());
graphics.fillRect(thumbBounds.x + 1, thumbBounds.y + 1, thumbBounds.width - 2, 2);
graphics.fillRect(thumbBounds.x + 1, thumbBounds.y + 1, 2, thumbBounds.height - 2);
}
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalBorderColor());
graphics.drawRect(thumbBounds.x, thumbBounds.y, thumbBounds.width - 1, thumbBounds.height - 1);
paintGripper(graphics, thumbBounds, thumbFillColor, isPressed, isRollover);
graphics.setColor(oldColor);
}
/**
* Paint the gripper for the scroll bar.
*
* @param graphics The graphics object used to paint the gripper.
* @param thumbBounds The bounds of the thumb to paint the gripper on.
* @param thumbFillColor The color with which the thumb is currently filled.
* @param isThumbPressed Is the thumb currently pressed?
* @param isThumbRollover Is the thumb currently in rollover mode?
*/
private void paintGripper (Graphics graphics, Rectangle thumbBounds, Color thumbFillColor, boolean isThumbPressed,
boolean isThumbRollover)
{
boolean isHorizontal = scrollbar.getOrientation() == SwingConstants.HORIZONTAL;
if ((isHorizontal && thumbBounds.getWidth() > 16) || (!isHorizontal && thumbBounds.getHeight() > 16))
{
int translatedX = 0;
int translatedY = 0;
Color shadow = thumbFillColor.darker();
Color highlight = thumbFillColor.brighter();
translatedX = thumbBounds.x + (thumbBounds.width >> 1) - 3;
translatedY = thumbBounds.y + (thumbBounds.height >> 1) - 3;
graphics.translate(translatedX, translatedY);
if(isHorizontal)
{
if (isThumbPressed || isThumbRollover)
{
graphics.translate(0, 1);
graphics.setColor(shadow);
paintHorizontalGripperPart(graphics);
graphics.setColor(highlight);
graphics.translate(1, 1);
paintHorizontalGripperPart(graphics);
graphics.translate(- 1, - 1);
graphics.translate(0, - 1);
}
else
{
graphics.setColor(highlight);
paintHorizontalGripperPart(graphics);
graphics.setColor(shadow);
graphics.translate(1, 1);
paintHorizontalGripperPart(graphics);
graphics.translate(- 1, - 1);
}
}
else
{
if (isThumbPressed || isThumbRollover)
{
graphics.translate(1, 0);
graphics.setColor(shadow);
paintVerticalGripperPart(graphics);
graphics.setColor(highlight);
graphics.translate(1, 1);
paintVerticalGripperPart(graphics);
graphics.translate(- 1, - 1);
graphics.translate(-1, 0);
}
else
{
graphics.setColor(highlight);
paintVerticalGripperPart(graphics);
graphics.setColor(shadow);
graphics.translate(1, 1);
paintVerticalGripperPart(graphics);
graphics.translate(- 1, - 1);
}
}
graphics.translate(-translatedX, -translatedY);
}
}
/**
* Paint one part of the gripper for a vertical scroll bar.
* A gripper conists of two parts, the highlight and the shadow part. They have the same structure.
* The only difference is that they are painted on different positions.
*
* @param graphics The graphics object used to paint the part.
*/
protected void paintVerticalGripperPart (Graphics graphics)
{
paintVerticalGripperPartColumn(graphics);
graphics.translate(4, 0);
paintVerticalGripperPartColumn(graphics);
graphics.translate(-4, 0);
}
/**
* Each vertical gripper part consists of two columns that look the same. The operation
* calling this operation has to translate the graphics to the right position.
*
* @param graphics The graphics object used to paint the part column.
*/
protected void paintVerticalGripperPartColumn (Graphics graphics)
{
graphics.drawLine(0, 0, 1, 0);
graphics.drawLine(0, 2, 1, 2);
graphics.drawLine(0, 4, 1, 4);
graphics.drawLine(0, 6, 1, 6);
}
/**
* Paint one part of the gripper for a horizontal scroll bar.
* A gripper conists of two parts, the highlight and the shadow part. They have the same structure.
* The only difference is that they are painted on different positions.
*
* @param graphics The graphics object used to paint the part.
*/
protected void paintHorizontalGripperPart (Graphics graphics)
{
paintHorizontalGripperPartRow(graphics);
graphics.translate(0, 4);
paintHorizontalGripperPartRow(graphics);
graphics.translate(0, -4);
}
/**
* Each horizontal gripper part consists of two columns that look the same. The operation
* calling this operation has to translate the graphics to the right position.
*
* @param graphics The graphics object used to paint the part column.
*/
protected void paintHorizontalGripperPartRow (Graphics graphics)
{
graphics.drawLine(0, 0 , 0, 1);
graphics.drawLine(2, 0 , 2, 1);
graphics.drawLine(4, 0 , 4, 1);
graphics.drawLine(6, 0 , 6, 1);
}
/**
* Paint the track of the scroll bar.
*
* @param graphics The graphics object used to paint the track.
* @param component The component (the scroll bar) to paint the track for.
* @param trackBounds The bounds of the track to paint.
*/
protected void paintTrack (Graphics graphics, JComponent component, Rectangle trackBounds)
{
Color oldColor = graphics.getColor();
if (Boolean.TRUE.equals(scrollbar.getClientProperty(SquarenessConstants.SCROLLBAR_TRACK_PRESSED_CLIENT_PROPERTY_KEY)))
{
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getPressedScrollBarTrackBackgroundColor());
}
else
{
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getProgressBarBackgroundColor());
}
graphics.fillRect(trackBounds.x, trackBounds.y, trackBounds.width - 1, trackBounds.height - 1);
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalBorderColor());
if (scrollbar.getOrientation() == JScrollBar.VERTICAL)
{
graphics.drawLine(trackBounds.x, 0, trackBounds.x, scrollbar.getHeight() - 1);
graphics.drawLine(trackBounds.width - 1, 0, trackBounds.width - 1, scrollbar.getHeight() - 1);
}
else
{
graphics.drawLine(0, trackBounds.y, scrollbar.getWidth() - 1, trackBounds.y);
graphics.drawLine(0, trackBounds.height - 1, scrollbar.getWidth() - 1, trackBounds.height - 1);
}
graphics.setColor(oldColor);
}
/**
* Create the button that is used to scroll down or right the scroll bar.
*
* @param orientation The orientation of the scrollbar (JScrollBar.HORIZONTAL or JScrollBar.VERTICAL)
* @return The created button
*/
protected JButton createIncreaseButton (int orientation)
{
UIDefaults defaults = UIManager.getDefaults();
int scrollbarWidth = defaults.getInt("ScrollBar.width");
final JButton button = new SquarenessScrollBarButton();
Dimension dimension = new Dimension(scrollbarWidth, scrollbarWidth);
button.setPreferredSize(dimension);
button.setMinimumSize(dimension);
if (scrollbar.getOrientation() == JScrollBar.HORIZONTAL)
{
button.setIcon(defaults.getIcon(SquarenessConstants.SCROLL_ARROW_RIGHT_KEY));
}
else
{
button.setIcon(defaults.getIcon(SquarenessConstants.SCROLL_ARROW_DOWN_KEY));
}
button.setHorizontalAlignment(SwingConstants.CENTER);
button.setVerticalAlignment(SwingConstants.CENTER);
return button;
}
/**
* Create the button that is used to scroll up or left the scroll bar.
*
* @param orientation The orientation of the scrollbar (JScrollBar.HORIZONTAL or JScrollBar.VERTICAL)
* @return The created button
*/
protected JButton createDecreaseButton (int orientation)
{
UIDefaults defaults = UIManager.getDefaults();
int scrollbarWidth = defaults.getInt("ScrollBar.width");
final JButton button = new SquarenessScrollBarButton();
Dimension dimension = new Dimension(scrollbarWidth, scrollbarWidth);
button.setPreferredSize(dimension);
button.setMinimumSize(dimension);
if (scrollbar.getOrientation() == JScrollBar.HORIZONTAL)
{
button.setIcon(defaults.getIcon(SquarenessConstants.SCROLL_ARROW_LEFT_KEY));
}
else
{
button.setIcon(defaults.getIcon(SquarenessConstants.SCROLL_ARROW_UP_KEY));
}
button.setHorizontalAlignment(SwingConstants.CENTER);
button.setVerticalAlignment(SwingConstants.CENTER);
return button;
}
private static class SquarenessScrollBarButton extends JButton
{
public Border getBorder ()
{
return _border;
}
private Border _border = SquarenessBorderFactory.getNonSpacingControlBorderWithMargin();
}
/**
* The mouse motion listener that observes wheter the scroll bar enters or exits roll over mode.
* The client property SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY is changed on the scroll bar accordingly.
*/
private class ScrollBarMouseMotionListener extends MouseMotionAdapter
{
public void mouseMoved (MouseEvent mouseEvent)
{
Rectangle thumbBounds = getThumbBounds();
if (thumbBounds.contains(mouseEvent.getPoint()))
{
if (scrollbar.getClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY).equals(Boolean.FALSE))
{
scrollbar.putClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY, Boolean.TRUE);
scrollbar.repaint(thumbBounds);
}
}
else
{
if (scrollbar.getClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY).equals(Boolean.TRUE))
{
scrollbar.putClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY, Boolean.FALSE);
scrollbar.repaint(thumbBounds);
}
}
}
}
/**
* The mouse listener that observes whether the thumb or track are clicked and sets the according
* client properties SquarenessConstants.SCROLLBAR_THUMB_PRESSED_CLIENT_PROPERTY_KEY
*/
private class ScrollBarMouseListener extends MouseAdapter
{
public void mousePressed (MouseEvent mouseEvent)
{
Rectangle thumbBounds = getThumbBounds();
Rectangle trackBounds = getTrackBounds();
if (thumbBounds.contains(mouseEvent.getPoint())
&& scrollbar.getClientProperty(SquarenessConstants.SCROLLBAR_THUMB_PRESSED_CLIENT_PROPERTY_KEY).equals(
Boolean.FALSE))
{
scrollbar.putClientProperty(SquarenessConstants.SCROLLBAR_THUMB_PRESSED_CLIENT_PROPERTY_KEY, Boolean.TRUE);
scrollbar.repaint(thumbBounds);
}
else if (trackBounds.contains(mouseEvent.getPoint())
&& scrollbar.getClientProperty(SquarenessConstants.SCROLLBAR_TRACK_PRESSED_CLIENT_PROPERTY_KEY).equals(
Boolean.FALSE))
{
scrollbar.putClientProperty(SquarenessConstants.SCROLLBAR_TRACK_PRESSED_CLIENT_PROPERTY_KEY, Boolean.TRUE);
scrollbar.repaint(trackBounds);
}
}
public void mouseReleased (MouseEvent mouseEvent)
{
Rectangle thumbBounds = getThumbBounds();
Rectangle trackBounds = getTrackBounds();
if (scrollbar.getClientProperty(SquarenessConstants.SCROLLBAR_THUMB_PRESSED_CLIENT_PROPERTY_KEY).equals(
Boolean.TRUE))
{
scrollbar.putClientProperty(SquarenessConstants.SCROLLBAR_THUMB_PRESSED_CLIENT_PROPERTY_KEY, Boolean.FALSE);
scrollbar.repaint(thumbBounds);
}
else if (scrollbar.getClientProperty(SquarenessConstants.SCROLLBAR_TRACK_PRESSED_CLIENT_PROPERTY_KEY).equals(
Boolean.TRUE))
{
scrollbar.putClientProperty(SquarenessConstants.SCROLLBAR_TRACK_PRESSED_CLIENT_PROPERTY_KEY, Boolean.FALSE);
scrollbar.repaint(trackBounds);
}
}
public void mouseExited (MouseEvent mouseEvent)
{
if (scrollbar.getClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY).equals(Boolean.TRUE))
{
scrollbar.putClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY, Boolean.FALSE);
scrollbar.repaint(getThumbBounds());
}
}
}
private ScrollBarMouseMotionListener _scrollBarMouseMotionListener;
private ScrollBarMouseListener _scrollBarMouseListener;
} squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessSliderUI.java 100644 0 0 20045 10563076303 24737 0 ustar 0 0 /*
Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of 'Robert F. Beeger' nor the names of his contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other
skins from the Squareness series.
*/
package net.beeger.squareness.delegate;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import javax.swing.JComponent;
import javax.swing.JSlider;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSliderUI;
import net.beeger.squareness.SquarenessLookAndFeel;
/**
* The Squareness Slider UI delegate.
*/
public class SquarenessSliderUI extends BasicSliderUI
{
/**
* Create an UI delegate for the given component.
*
* @param component The component for which to create the UI delegate.
* @return The created UI delegate.
*/
public static ComponentUI createUI (JComponent component)
{
return new SquarenessSliderUI((JSlider) component);
}
/**
* Create the UI delegate.
*
* @param slider The slider for which this delegate will be used.
*/
public SquarenessSliderUI (JSlider slider)
{
super(slider);
}
/**
* Paint the track of the slider.
*
* @param graphics The graphics object to use for painting the track.
*/
public void paintTrack (Graphics graphics)
{
Color oldColor = graphics.getColor();
int x, y, width, height;
if (slider.getOrientation() == JSlider.HORIZONTAL)
{
x = trackRect.x;
y = trackRect.y + (trackRect.height >> 1) - 2;
width = trackRect.width;
height = 5;
}
else
{
x = trackRect.x + (trackRect.width >> 1) - 2;
y = trackRect.y;
width = 5;
height = trackRect.height;
}
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getProgressBarBackgroundColor());
graphics.fillRect(x, y, width, height);
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalBorderColor());
graphics.drawRect(x, y, width - 1, height - 1);
if (slider.getClientProperty("JSlider.isFilled") != null
&& ((Boolean) slider.getClientProperty("JSlider.isFilled")).booleanValue())
{
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getSelectedControlBackgroundColor());
if (slider.getOrientation() == JSlider.HORIZONTAL)
{
if (drawInverted())
{
graphics.fillRect(thumbRect.x, y + 1, width - 2 - (thumbRect.x - x), height - 2);
}
else
{
graphics.fillRect(x + 1, y + 1, thumbRect.x - x, height - 2);
}
}
else
{
if (drawInverted())
{
graphics.fillRect(x + 1, thumbRect.y, width - 2 - (thumbRect.y - y), height - 2);
}
else
{
graphics.fillRect(x + 1, y + 1, width - 2, thumbRect.y - y);
}
}
}
graphics.setColor(oldColor);
}
/**
* Paint the thumb of the slider.
*
* @param graphics The graphics object to use for the painting.
*/
public void paintThumb (Graphics graphics)
{
Color oldColor = graphics.getColor();
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalControlBackgroundColor());
graphics.fillRect(thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height);
if (slider.isEnabled())
{
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalBorderColor());
}
else
{
graphics.setColor(SquarenessLookAndFeel.getCurrentSquarenessTheme().getDisabledBorderColor());
}
graphics.drawRect(thumbRect.x, thumbRect.y, thumbRect.width - 1, thumbRect.height - 1);
if (slider.getPaintTicks())
{
int yBot = thumbRect.y + thumbRect.height - 1;
int xRight = thumbRect.x + thumbRect.width - 1;
if (slider.getOrientation() == JSlider.HORIZONTAL)
{
graphics.drawLine(thumbRect.x + 2, yBot - 5, thumbRect.x + 5, yBot - 2);
graphics.drawLine(thumbRect.x + 3, yBot - 5, thumbRect.x + 5, yBot - 3);
graphics.drawLine(thumbRect.x + 3, yBot - 6, thumbRect.x + 5, yBot - 4);
graphics.drawLine(xRight - 2, yBot - 5, thumbRect.x + 5, yBot - 2);
graphics.drawLine(xRight - 3, yBot - 5, thumbRect.x + 5, yBot - 3);
graphics.drawLine(xRight - 3, yBot - 6, thumbRect.x + 5, yBot - 4);
}
else
{
graphics.drawLine(xRight - 5, thumbRect.y + 2, xRight - 2, thumbRect.y + 5);
graphics.drawLine(xRight - 5, thumbRect.y + 3, xRight - 3, thumbRect.y + 5);
graphics.drawLine(xRight - 6, thumbRect.y + 3, xRight - 4, thumbRect.y + 5);
graphics.drawLine(xRight - 5, yBot - 2, xRight - 2, thumbRect.y + 5);
graphics.drawLine(xRight - 5, yBot - 3, xRight - 3, thumbRect.y + 5);
graphics.drawLine(xRight - 6, yBot - 3, xRight - 4, thumbRect.y + 5);
}
}
graphics.setColor(oldColor);
}
/**
* Paint a minor tick for a horizontal slider.
*
* @param graphics The graphics object to use for painting.
* @param tickBounds The bounds of the tick.
* @param x The x position at which to paint the tick.
*/
protected void paintMinorTickForHorizSlider (Graphics graphics, Rectangle tickBounds, int x)
{
graphics.drawLine(x, 1, x, (tickBounds.height >> 1) - 1);
}
/**
* Paint a major tick for a horizontal slider.
*
* @param graphics The graphics object to use for painting.
* @param tickBounds The bounds of the tick.
* @param x The x position at which to paint the tick.
*/
protected void paintMajorTickForHorizSlider (Graphics graphics, Rectangle tickBounds, int x)
{
graphics.drawLine(x, 1, x, tickBounds.height - 2);
}
/**
* Paint a minor tick for a vertical slider.
*
* @param graphics The graphics object to use for painting.
* @param tickBounds The bounds of the tick.
* @param y The y position at which to paint the tick.
*/
protected void paintMinorTickForVertSlider (Graphics graphics, Rectangle tickBounds, int y)
{
graphics.drawLine(1, y, (tickBounds.width >> 1) - 1, y);
}
/**
* Paint a major tick for a vertical slider.
*
* @param graphics The graphics object to use for painting.
* @param tickBounds The bounds of the tick.
* @param y The y position at which to paint the tick.
*/
protected void paintMajorTickForVertSlider (Graphics graphics, Rectangle tickBounds, int y)
{
graphics.drawLine(1, y, tickBounds.width - 2, y);
}
} squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessSpinnerUI.java 100644 0 0 10465 10563076303 25140 0 ustar 0 0 /*
Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of 'Robert F. Beeger' nor the names of his contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other
skins from the Squareness series.
*/
package net.beeger.squareness.delegate;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSpinnerUI;
import net.beeger.squareness.SquarenessConstants;
/**
* The Squareness Spinner UI Delegate.
*/
public class SquarenessSpinnerUI extends BasicSpinnerUI
{
/**
* Create the UI delegate for the given component
*
* @param component The component for which to create the ui delegate
* @return The created ui delegate
*/
public static ComponentUI createUI (JComponent component)
{
return new SquarenessSpinnerUI();
}
/**
* Install the UI delegate for the given component.
*
* @param component The component for which to install the UI delegate.
*/
public void installUI (JComponent component)
{
super.installUI(component);
_nextButton.addActionListener(SwingUtilities.getUIActionMap(spinner).get("increment"));
_nextButton.addMouseListener((MouseListener) SwingUtilities.getUIActionMap(spinner).get("increment"));
_previousButton.addActionListener(SwingUtilities.getUIActionMap(spinner).get("decrement"));
_previousButton.addMouseListener((MouseListener) SwingUtilities.getUIActionMap(spinner).get("decrement"));
}
/**
* Create the button which increases the value of the spinner.
*
* @return The created button
*/
protected Component createNextButton ()
{
_nextButton = new JButton(UIManager.getIcon(SquarenessConstants.SPIN_UP_KEY));
_nextButton.setPreferredSize(new Dimension(16, 16));
_nextButton.setMinimumSize(new Dimension(5, 5));
_nextButton.setHorizontalAlignment(SwingConstants.CENTER);
_nextButton.setVerticalAlignment(SwingConstants.CENTER);
return _nextButton;
}
/**
* Create the button which decreases the value of the spinner.
*
* @return The create button
*/
protected Component createPreviousButton ()
{
_previousButton = new JButton(UIManager.getIcon(SquarenessConstants.SPIN_DOWN_KEY));
_previousButton.setPreferredSize(new Dimension(16, 16));
_previousButton.setMinimumSize(new Dimension(5, 5));
_previousButton.setHorizontalAlignment(SwingConstants.CENTER);
_previousButton.setVerticalAlignment(SwingConstants.CENTER);
return _previousButton;
}
private JButton _previousButton;
private JButton _nextButton;
} squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessTabbedPaneUI.java 100644 0 0 43447 10563076303 25515 0 ustar 0 0 /*
Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of 'Robert F. Beeger' nor the names of his contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other
skins from the Squareness series.
*/
package net.beeger.squareness.delegate;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import javax.swing.JComponent;
import javax.swing.JTabbedPane;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTabbedPaneUI;
import net.beeger.squareness.SquarenessLookAndFeel;
/**
* The Squareness Tabbed Pane UI delegate.
*/
public class SquarenessTabbedPaneUI extends BasicTabbedPaneUI
{
/**
* Create the UI delegate for the given component.
*
* @param component The component for which to create an UI delegate.
* @return The created UI delegate.
*/
public static ComponentUI createUI(JComponent component)
{
return new SquarenessTabbedPaneUI();
}
/**
* Install the UI delegate for the given component.
*
* @param component The component for which to install the UI delegate.
*/
public void installUI(JComponent component)
{
super.installUI(component);
_tabbedBarMouseListener = new TabbedPaneMouseListener();
_tabbedBarMouseMotionListener = new TabbedPaneMouseMotionListener();
tabPane.addMouseListener(_tabbedBarMouseListener);
tabPane.addMouseMotionListener(_tabbedBarMouseMotionListener);
}
/**
* Uninstall the UI delegate from the given component.
*
* param component The component from which to uninstall the UI delegate.
*/
public void uninstallUI(JComponent component)
{
tabPane.removeMouseListener(_tabbedBarMouseListener);
tabPane.removeMouseMotionListener(_tabbedBarMouseMotionListener);
super.uninstallUI(component);
}
/**
* Paint the background of the tab at index tabIndex.
*
* @param graphics The graphics object to use for painting.
* @param tabPlacement The placement of the tabs (TOP, BOTTOM, LEFT, RIGHT)
* @param tabIndex The index of the tab to paint the background for.
* @param x The x position of the tab
* @param y The y position of the tab
* @param width The width of the tab
* @param height The height of the tab
* @param isSelected Is the tab currently selected?
*/
protected void paintTabBackground(Graphics graphics, int tabPlacement, int tabIndex,
int x, int y, int width, int height, boolean isSelected)
{
Color oldColor = graphics.getColor();
Color background;
if (!isSelected && _mouseOverTab == tabIndex)
{
background = SquarenessLookAndFeel.getCurrentSquarenessTheme().getSelectedControlBackgroundColor();
}
else
{
background = SquarenessLookAndFeel.getCurrentSquarenessTheme().getWindowBackgroundColor();
}
graphics.setColor(background);
graphics.fillRect(x, y, width, height);
graphics.setColor(oldColor);
}
/**
* Paint the border of the tab at tabIndex.
*
* @param graphics The graphics object to use for painting.
* @param tabPlacement The placement of the tabs (TOP, BOTTOM, LEFT, RIGHT)
* @param tabIndex The index of the tab to paint the border for.
* @param x The x position of the tab
* @param y The y position of the tab
* @param width The width of the tab
* @param height The height of the tab
* @param isSelected Is the tab currently selected?
*/
protected void paintTabBorder(Graphics graphics, int tabPlacement, int tabIndex,
int x, int y, int width, int height, boolean isSelected)
{
Color oldColor = graphics.getColor();
Color borderColor;
if (!isSelected && _mouseOverTab == tabIndex)
{
borderColor = SquarenessLookAndFeel.getCurrentSquarenessTheme().getSelectedControlBackgroundColor().darker();
}
else
{
borderColor = SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalBorderColor();
}
graphics.setColor(borderColor);
graphics.translate(x, y);
if (isSelected || _mouseOverTab == tabIndex)
{
switch (tabPlacement)
{
case JTabbedPane.TOP:
paintHorizontalTabBorder(graphics, height, width, true);
break;
case JTabbedPane.BOTTOM:
paintHorizontalTabBorder(graphics, height, width, false);
break;
case JTabbedPane.LEFT:
paintVerticalTabBorder(graphics, height, width, true);
break;
case JTabbedPane.RIGHT:
paintVerticalTabBorder(graphics, height, width, false);
break;
}
}
else
{
int tabCount = tabPane.getTabCount();
if (lastTabInRun(tabCount, getRunForTab(tabCount, tabIndex)) != tabIndex
&& tabPane.getSelectedIndex() - tabIndex != 1)
{
switch (tabPlacement)
{
case JTabbedPane.TOP:
case JTabbedPane.BOTTOM:
graphics.drawLine(width - 1, 3, width - 1, height - 1 - 3);
break;
case JTabbedPane.LEFT:
case JTabbedPane.RIGHT:
graphics.drawLine(4, height - 1, width - 1 - 4, height - 1);
break;
}
}
}
graphics.translate(-x, -y);
graphics.setColor(oldColor);
}
/**
* Paint a border for a vertical tab that is either selected or in mouse over mode.
*
* @param graphics The graphics object to use for painting.
* @param height The height of the tab
* @param width The width of the tab.
* @param isPlacedLeft Are the tabs placed on the left side?
*/
private void paintVerticalTabBorder(Graphics graphics, int height, int width, boolean isPlacedLeft)
{
graphics.drawLine(0, 0, width - 1, 0);
if (isPlacedLeft)
{
graphics.drawLine(0, 0, 0, height - 1);
graphics.drawLine(0, height - 1, width - 1, height - 1);
}
else
{
graphics.drawLine(width - 1, 0, width - 1, height - 1);
graphics.drawLine(0, height - 1, width - 1, height - 1);
}
}
/**
* Paint a border for a horizontal tab that is either selected or in mouse over mode.
*
* @param graphics The graphics object to use for painting.
* @param height The height of the tab
* @param width The width of the tab.
* @param isPlacedTop Are the tabs placed at the top?
*/
private void paintHorizontalTabBorder(Graphics graphics, int height, int width, boolean isPlacedTop)
{
graphics.drawLine(0, 0, 0, height - 1);
graphics.drawLine(width - 1, 0, width - 1, height - 1);
if (isPlacedTop)
{
graphics.drawLine(0, 0, width - 1, 0);
}
else
{
graphics.drawLine(0, height - 1, width - 1, height - 1);
}
}
/**
* Paint the top border of the content of the tabbed pane.
*
* @param graphics The graphics object to use for painting
* @param tabPlacement The placement of the tabs (TOP,BOTTOM,LEFT,RIGHT)
* @param selectedIndex The index of the selected tab
* @param x The x position of the content pane.
* @param y The y position of the content pane
* @param width The width of the content pane
* @param height The height of the content pane
*/
protected void paintContentBorderTopEdge(Graphics graphics, int tabPlacement, int selectedIndex,
int x, int y, int width, int height)
{
Color oldColor = graphics.getColor();
Color borderColor = SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalBorderColor();
graphics.setColor(borderColor);
// Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect);
Rectangle selRect = selectedIndex < 0 ? null : getTabBoundsNoCheckLayout(selectedIndex);
if (tabPlacement != TOP || selectedIndex < 0 ||
(selRect.y + selRect.height + 1 < y) ||
(selRect.x < x || selRect.x > x + width))
{
graphics.drawLine(x, y, x + width - 1, y);
}
else
{
graphics.drawLine(x, y, selRect.x, y);
if (selRect.x + selRect.width < x + width - 1)
{
graphics.drawLine(selRect.x + selRect.width - 1, y, x + width - 1, y);
}
}
graphics.setColor(oldColor);
}
/**
* Paint the right border of the content of the tabbed pane.
*
* @param graphics The graphics object to use for painting
* @param tabPlacement The placement of the tabs (TOP,BOTTOM,LEFT,RIGHT)
* @param selectedIndex The index of the selected tab
* @param x The x position of the content pane.
* @param y The y position of the content pane
* @param width The width of the content pane
* @param height The height of the content pane
*/
protected void paintContentBorderRightEdge(Graphics graphics, int tabPlacement, int selectedIndex,
int x, int y, int width, int height)
{
Color oldColor = graphics.getColor();
Color borderColor = SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalBorderColor();
graphics.setColor(borderColor);
// Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect);
Rectangle selRect = selectedIndex < 0 ? null : getTabBoundsNoCheckLayout(selectedIndex);
if (tabPlacement != RIGHT || selectedIndex < 0 ||
(selRect.x - 1 > width) ||
(selRect.y < y || selRect.y > y + height))
{
graphics.drawLine(x + width - 1, y, x + width - 1, y + height - 1);
}
else
{
graphics.drawLine(x + width - 1, y, x + width - 1, selRect.y);
if (selRect.y + selRect.height < y + height - 1)
{
graphics.drawLine(x + width - 1, selRect.y + selRect.height - 1, x + width - 1, y + height - 1);
}
}
graphics.setColor(oldColor);
}
/**
* Paint the left border of the content of the tabbed pane.
*
* @param graphics The graphics object to use for painting
* @param tabPlacement The placement of the tabs (TOP,BOTTOM,LEFT,RIGHT)
* @param selectedIndex The index of the selected tab
* @param x The x position of the content pane.
* @param y The y position of the content pane
* @param width The width of the content pane
* @param height The height of the content pane
*/
protected void paintContentBorderLeftEdge(Graphics graphics, int tabPlacement, int selectedIndex,
int x, int y, int width, int height)
{
Color oldColor = graphics.getColor();
Color borderColor = SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalBorderColor();
graphics.setColor(borderColor);
// Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect);
Rectangle selRect = selectedIndex < 0 ? null : getTabBoundsNoCheckLayout(selectedIndex);
if (tabPlacement != LEFT || selectedIndex < 0 ||
(selRect.x + selRect.width + 1 < x) ||
(selRect.y < y || selRect.y > y + height))
{
graphics.drawLine(x, y, x, y + height - 1);
}
else
{
graphics.drawLine(x, y, x, selRect.y);
if (selRect.y + selRect.height < y + height - 1)
{
graphics.drawLine(x, selRect.y + selRect.height - 1, x, y + height - 1);
}
}
graphics.setColor(oldColor);
}
/**
* Paint the bottom border of the content of the tabbed pane.
*
* @param graphics The graphics object to use for painting
* @param tabPlacement The placement of the tabs (TOP,BOTTOM,LEFT,RIGHT)
* @param selectedIndex The index of the selected tab
* @param x The x position of the content pane.
* @param y The y position of the content pane
* @param width The width of the content pane
* @param height The height of the content pane
*/
protected void paintContentBorderBottomEdge(Graphics graphics, int tabPlacement, int selectedIndex,
int x, int y, int width, int height)
{
Color oldColor = graphics.getColor();
Color borderColor = SquarenessLookAndFeel.getCurrentSquarenessTheme().getNormalBorderColor();
graphics.setColor(borderColor);
// Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect);
Rectangle selRect = selectedIndex < 0 ? null : getTabBoundsNoCheckLayout(selectedIndex);
if (tabPlacement != BOTTOM || selectedIndex < 0 ||
(selRect.y - 1 > height) ||
(selRect.x < x || selRect.x > x + width))
{
graphics.drawLine(x, y + height - 1, x + width - 1, y + height - 1);
}
else
{
graphics.drawLine(x, y + height - 1, selRect.x, y + height - 1);
if (selRect.x + selRect.width < x + width - 1)
{
graphics.drawLine(selRect.x + selRect.width - 1, y + height - 1, x + width - 1, y + height - 1);
}
}
graphics.setColor(oldColor);
}
protected boolean isTabVisible(int index)
{
return index < rects.length && rects[index] != null;
}
protected Rectangle getTabBoundsNoCheckLayout(int index)
{
Rectangle result = new Rectangle();
getTabBounds(index, result);
return result;
}
public void paint(Graphics g, JComponent c)
{
Rectangle allTabBounds = null;
for (int i = 0; i < tabPane.getTabCount(); i++)
{
if (isTabVisible(i))
{
Rectangle tabBounds = getTabBoundsNoCheckLayout(i);
if (allTabBounds == null)
{
allTabBounds = tabBounds;
}
else
{
allTabBounds.add(tabBounds);
}
}
}
if (allTabBounds != null && allTabBounds.contains(g.getClipBounds()))
{
if (!(tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT))
{
paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
}
}
else
{
super.paint(g, c);
}
}
/**
* The mouse motion listener that observes wheter the tabbed pane enters or exits roll over mode.
*/
private class TabbedPaneMouseMotionListener extends MouseMotionAdapter
{
public void mouseMoved(MouseEvent mouseEvent)
{
boolean found = false;
for (int i = 0; !found && i < tabPane.getTabCount(); i++)
{
if (isTabVisible(i))
{
Rectangle tabBounds = getTabBoundsNoCheckLayout(i);
if (tabBounds.contains(mouseEvent.getPoint()))
{
found = true;
if (_mouseOverTab != i)
{
if (_mouseOverTab >= 0 && isTabVisible(_mouseOverTab) && tabPane.getSelectedIndex() != _mouseOverTab)
{
tabPane.repaint(getTabBoundsNoCheckLayout(_mouseOverTab));
}
if (tabPane.getSelectedIndex() != i)
{
tabPane.repaint(tabBounds);
}
_mouseOverTab = i;
}
}
}
}
if (!found && _mouseOverTab >= 0)
{
if (_mouseOverTab < tabPane.getTabCount() && isTabVisible(_mouseOverTab) && tabPane.getSelectedIndex() != _mouseOverTab)
{
tabPane.repaint(getTabBoundsNoCheckLayout(_mouseOverTab));
}
_mouseOverTab = -1;
}
}
}
/**
* The mouse listener that observes whether the tabbed pane exits rollover mode.
*/
private class TabbedPaneMouseListener extends MouseAdapter
{
public void mouseExited(MouseEvent mouseEvent)
{
if (_mouseOverTab >= 0)
{
if (_mouseOverTab < tabPane.getTabCount() && isTabVisible(_mouseOverTab) && tabPane.getSelectedIndex() != _mouseOverTab)
{
tabPane.repaint(getTabBoundsNoCheckLayout(_mouseOverTab));
}
_mouseOverTab = -1;
}
}
}
private TabbedPaneMouseMotionListener _tabbedBarMouseMotionListener;
private TabbedPaneMouseListener _tabbedBarMouseListener;
private int _mouseOverTab = -1;
} squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessToggleButtonUI.java 100644 0 0 13571 10563076303 26140 0 ustar 0 0 /*
Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of 'Robert F. Beeger' nor the names of his contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other
skins from the Squareness series.
*/
package net.beeger.squareness.delegate;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.plaf.basic.BasicToggleButtonUI;
import javax.swing.text.View;
import net.beeger.squareness.SquarenessConstants;
import net.beeger.squareness.util.SquarenessButtonPainter;
import net.beeger.squareness.util.SquarenessListenerFactory;
/**
* The Squareness Toggle Button UI delegate.
*/
public class SquarenessToggleButtonUI extends BasicToggleButtonUI
{
/**
* Create the UI delegate for the given component
*
* @param component The component for which to create the ui delegate
* @return The created ui delegate
*/
public static ComponentUI createUI (JComponent component)
{
return _buttonUI;
}
/**
* Install the UI delegate for the given component
*
* @param component The component for which to install the ui delegate.
*/
public void installUI (JComponent component)
{
component.putClientProperty(SquarenessConstants.ROLLOVER_CLENT_PROPERTY_KEY, Boolean.FALSE);
component.addMouseListener(SquarenessListenerFactory.getButtonRolloverMouseListener());
super.installUI(component);
}
/**
* Uninstall the UI delegate from the given component.
*
* @param component The component from which to uninstall the UI delegate.
*/
public void uninstallUI (JComponent component)
{
component.removeMouseListener(SquarenessListenerFactory.getButtonRolloverMouseListener());
super.uninstallUI(component);
}
/**
* Paint the component.
*
* @param graphics The graphics resource used to paint the component
* @param component The component to paint.
*/
public void paint (Graphics graphics, JComponent component)
{
Color oldColor = graphics.getColor();
SquarenessButtonPainter.paintButton(graphics, (AbstractButton) component);
AbstractButton b = (AbstractButton) component;
ButtonModel model = b.getModel();
Dimension size = b.getSize();
FontMetrics fm = graphics.getFontMetrics();
Insets i = component.getInsets();
Rectangle viewRect = new Rectangle(size);
viewRect.x += i.left;
viewRect.y += i.top;
viewRect.width -= (i.right + viewRect.x);
viewRect.height -= (i.bottom + viewRect.y);
Rectangle iconRect = new Rectangle();
Rectangle textRect = new Rectangle();
Font f = component.getFont();
graphics.setFont(f);
// layout the text and icon
String text = SwingUtilities.layoutCompoundLabel(component, fm, b.getText(), b.getIcon(),
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewRect, iconRect, textRect,
b.getText() == null ? 0 : b.getIconTextGap());
graphics.setColor(b.getBackground());
if (model.isArmed() && model.isPressed() || model.isSelected())
{
paintButtonPressed(graphics, b);
}
// Paint the Icon
if (b.getIcon() != null)
{
paintIcon(graphics, b, iconRect);
}
// Draw the Text
if (text != null && !text.equals(""))
{
View v = (View) component.getClientProperty(BasicHTML.propertyKey);
if (v != null)
{
v.paint(graphics, textRect);
}
else
{
paintText(graphics, b, textRect, text);
}
}
// draw the dashed focus line.
if (b.isFocusPainted() && b.hasFocus())
{
paintFocus(graphics, b, viewRect, textRect, iconRect);
}
graphics.setColor(oldColor);
}
private static SquarenessToggleButtonUI _buttonUI = new SquarenessToggleButtonUI();
} squareness-2.3.0/source/net/beeger/squareness/delegate/SquarenessToolBarUI.java 100644 0 0 10403 10563076303 25054 0 ustar 0 0 /*
Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of 'Robert F. Beeger' nor the names of his contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other
skins from the Squareness series.
*/
package net.beeger.squareness.delegate;
import java.awt.Component;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import javax.swing.AbstractButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JToggleButton;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicToolBarUI;
import net.beeger.squareness.util.SquarenessBorderFactory;
/**
* The Squareness Tool Bar UI delegate.
*/
public class SquarenessToolBarUI extends BasicToolBarUI
{
/**
* Create the ui delegate for the given component
*
* @param component The component for which to create the ui delegate
* @return The created ui delegate
*/
public static ComponentUI createUI (JComponent component)
{
return new SquarenessToolBarUI();
}
/**
* Install the UI delegate for the given component.
*
* @param component The component for which to install the UI delegate.
*/
public void installUI (JComponent component)
{
super.installUI(component);
toolBar.addContainerListener(new ContainerListener()
{
public void componentAdded (ContainerEvent e)
{
JComponent child = (JComponent) e.getChild();
}
public void componentRemoved (ContainerEvent e)
{
}
});
}
/**
* Create a rollover border. This border will be used if rollover borders are enabled.
*/
protected Border createRolloverBorder ()
{
return SquarenessBorderFactory.getButtonRolloverBorder();
}
/**
* Create a non rollover border. This border will be used if rollover borders are disabled.
*/
protected Border createNonRolloverBorder ()
{
return SquarenessBorderFactory.getButtonNonRolloverBorder();
}
/**
* Set the non rollover border on the given component.
*
* @param component The component to set the non rollover border on.
*/
protected void setBorderToNonRollover (Component component)
{
super.setBorderToNonRollover(component);
if (component instanceof AbstractButton)
{
AbstractButton button = (AbstractButton) component;
if (button.getBorder() instanceof UIResource)
{
if (button instanceof JToggleButton && !(button instanceof JCheckBox))
{
// only install this border for the ToggleButton
button.setBorder(SquarenessBorderFactory.getButtonNonRolloverBorder());
}
}
}
}
} squareness-2.3.0/source/net/beeger/squareness/icons/Error.gif 100644 0 0 234 10563076303 21421 0 ustar 0 0 GIF89a € "9Iö˜Ÿ!ù ÿ , @s„©›áÞž„hš‰ƒÊÈÈQÇç=WÈT˜Úf•ÁèÝáz.Ú,)Å|®ÙqÖÊW3(sF½]ueÝù²©'w9ÛþT°ârJŸb—ÛEþp›d²>ŸÞpÒ´çeÃÈ%&E¦t˜×÷¥Ç Y ; squareness-2.3.0/source/net/beeger/squareness/icons/Inform.gif 100644 0 0 206 10563076303 21561 0 ustar 0 0 GIF89a € "9I°áì!ù ÿ , @]„©›áŠ4˜'~wËæY@HV§¡c˜ng ¿0)› Jßîª"yîcñvAœ°¸›ÍjJ³IyBZÎaY~P¡Vʱڰ¶¯8zÎè²Ç·
þ˜¹ÝdÈÈë ; squareness-2.3.0/source/net/beeger/squareness/icons/Question.gif 100644 0 0 213 10563076303 22134 0 ustar 0 0 GIF89a € "9I¢íe!ù ÿ , @b„©›áÁb{æY+§«—êÞqàHb@Y*&™©
ƒbLÏžÞ½¬ô…ƒèd<Û0‡øÍ€Ôò—:B£Ó˜±(}í°ß†›ÔVƒÏÚ§lºy‘¼5³èNwͬ&utf«9¾|S ; squareness-2.3.0/source/net/beeger/squareness/icons/Warn.gif 100644 0 0 205 10563076303 21235 0 ustar 0 0 GIF89a € "9Iþ÷6!ù ÿ , @\„©›áŠ4˜'~wËæY@HV§¡cÉ~m{¾aŒ¥m‚*i׫Šàýn:¢08ÊŒËdÓ™Dî¢á±
b§ZÅ›)ú®`H™#Î=¹D)³«T¯ÇóãŽG ; squareness-2.3.0/source/net/beeger/squareness/icons/computer.gif 100644 0 0 214 10563076303 22164 0 ustar 0 0 GIF89a ƒ "9IËšûÒEÀÀÀÿÿÿ !ù , 9H0ª½A±×œ÷mÔdžä lÛJéêºp(Ïl]â/¸ó
ô
Â.yj¦.èÓ¥F›§ ; squareness-2.3.0/source/net/beeger/squareness/icons/detail.gif 100644 0 0 173 10563076303 21574 0 ustar 0 0 GIF89a ƒ "9IËšûÒEÀÀÀÿÿÿ !ù , (pÈI«½h\! 7y_¨™J‚bz†m,[§LÂâjnjú±¹×l8‹ ; squareness-2.3.0/source/net/beeger/squareness/icons/document.gif 100644 0 0 203 10563076303 22142 0 ustar 0 0 GIF89a ƒ "9IËšûÒEÀÀÀÿÿÿ !ù , 0ÈI‡½€èåµ·eÀGR]‡‰ã²©{NEì„ç³}ë;0X#ølEbRylJ" ; squareness-2.3.0/source/net/beeger/squareness/icons/floppy.gif 100644 0 0 214 10563076303 21637 0 ustar 0 0 GIF89a ƒ "9IËšûÒEÀÀÀÿÿÿ !ù , 9ÈIé@ˆ
ˆÏ ¦q‘m'ùiU¶,'±Zmß3*Ã[é›´‰×ùP£×ˆì™¹Î0X4¶v² ; squareness-2.3.0/source/net/beeger/squareness/icons/folderclosed.gif 100644 0 0 112 10563076303 22770 0 ustar 0 0 GIF89a € ûÒE"9I!ù ÿ , !ŒiÀí¾ždq¾jÎ`go)|%ž¨*©°K ; squareness-2.3.0/source/net/beeger/squareness/icons/folderopened.gif 100644 0 0 203 10563076303 22772 0 ustar 0 0 GIF89a ƒ "9IËšûÒEÀÀÀÿÿÿ !ù ÿ , 0ÈI«8k}-ØAGŒäÇ} ©š˜¨ŽlèÍ’`ß8^ç¼½÷¹ð&
ŠC$PÙ£Í" ; squareness-2.3.0/source/net/beeger/squareness/icons/folderup.gif 100644 0 0 117 10563076303 22150 0 ustar 0 0 GIF89a € "9IûÒE!ù ÿ , &„iÁí¾x,¶CmXzÏúyPHIdy%(Ý™fe*0Jãö ; squareness-2.3.0/source/net/beeger/squareness/icons/hd.gif 100644 0 0 213 10563076303 20720 0 ustar 0 0 GIF89a ƒ "9IÿCÿAûÒE !ù ÿ , 8ÈI«8k}qdãhiŠ$¨$èQìfÏ÷ÝêT—2€`‡‚¢QäûäH«'N
µX% ; squareness-2.3.0/source/net/beeger/squareness/icons/home.gif 100644 0 0 213 10563076303 21255 0 ustar 0 0 GIF89a ƒ "9IûÒEÿÿÿ !ù ÿ , 8ÈI«8k}·Ç—e¡`ž(@ª ê
,û¦ë*Nõç…8HÕ-X&(, A§É¤òáŒÍTgÞ& ; squareness-2.3.0/source/net/beeger/squareness/icons/list.gif 100644 0 0 206 10563076303 21302 0 ustar 0 0 GIF89a ƒ "9IËšûÒEÀÀÀÿÿÿ !ù , 3pÈI«½h«A&„÷… ’¢ zÚ)J*9t[Icx~u\
¯Õ+Æú[À’v³ñtÐ\ ; squareness-2.3.0/source/net/beeger/squareness/icons/treecollapsed.gif 100644 0 0 71 10563076303 23135 0 ustar 0 0 GIF89a € "9IÛÄc!ù ÿ , „¡ aÍVtÙ‰q…õš ; squareness-2.3.0/source/net/beeger/squareness/icons/treeexpanded.gif 100644 0 0 70 10563076303 22756 0 ustar 0 0 GIF89a € "9IÛÄc!ù ÿ , „¡Æë^CÈy㫨 ; squareness-2.3.0/source/net/beeger/squareness/theme/DefaultSquarenessTheme.java 100644 0 0 7157 10563076303 25147 0 ustar 0 0 /*
Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of 'Robert F. Beeger' nor the names of his contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other
skins from the Squareness series.
*/
package net.beeger.squareness.theme;
import javax.swing.plaf.ColorUIResource;
/**
* Created by IntelliJ IDEA.
* User: Robert F. Beeger
* Date: 22.08.2004
* Time: 20:12:55
* To change this template use File | Settings | File Templates.
*/
public class DefaultSquarenessTheme extends SquarenessTheme
{
public String getName ()
{
return "Original";
}
public ColorUIResource getDesktopColor ()
{
return new ColorUIResource(234, 216, 164);
}
public ColorUIResource getWindowBackgroundColor ()
{
return new ColorUIResource(247,242,225);
}
public ColorUIResource getDisabledBorderColor ()
{
return new ColorUIResource(134, 144, 150);
}
public ColorUIResource getNormalBorderColor ()
{
return new ColorUIResource(34, 57, 73);
}
public ColorUIResource getSelectedControlBackgroundColor ()
{
return new ColorUIResource(211, 211, 42);
}
public ColorUIResource getInactiveWindowBorderColor ()
{
return new ColorUIResource(184,175,119);
}
public ColorUIResource getDefaultButtonBorderColor ()
{
return new ColorUIResource(170,59,34);
}
public ColorUIResource getNormalControlBackgroundColor ()
{
return new ColorUIResource(219,196,99);
}
public ColorUIResource getSelectedControlBackgroundShadowColor ()
{
return new ColorUIResource(163,159,28);
}
public ColorUIResource getProgressBarBackgroundColor ()
{
return new ColorUIResource(245,246,220);
}
public ColorUIResource getPressedScrollBarTrackBackgroundColor ()
{
return new ColorUIResource(237,225,185);
}
public ColorUIResource getTextInputBackgroundColor ()
{
return new ColorUIResource(255,255,255);
}
public ColorUIResource getTextColor ()
{
return new ColorUIResource(0,0,0);
}
public boolean isDark ()
{
return false;
}
} squareness-2.3.0/source/net/beeger/squareness/theme/PropertiesSquarenessTheme.java 100644 0 0 26566 10563076303 25744 0 ustar 0 0 /*
Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of 'Robert F. Beeger' nor the names of his contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other
skins from the Squareness series.
*/
package net.beeger.squareness.theme;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import javax.swing.plaf.ColorUIResource;
/**
* This SquarenessTheme implementation can be configured from some sort of property bundle - * be it a resource bundle, a properties object or a properties file.
*A file matching the original Squareness theme would look like this:
*
*
*
* themeName = Original
* desktopColor = 234, 216, 164
* windowBackgroundColor = 247,242,225
* inactiveWindowBorderColor = 184,175,119
* normalBorderColor = 34, 57, 73
* disabledBorderColor = 134, 144, 150
* defaultButtonBorderColor = 170,59,34
* normalControlBackgroundColor = 219,196,99
* selectedControlBackgroundColor = 211, 211, 42
* selectedControlBackgroundShadowColor = 163,159,28
* progressBarBackgroundColor = 245,246,220
* pressedScrollBarTrackBackgroundColor = 237,225,185
* textInputBackgroundColor = 255,255,255
* textColor = 0,0,0
*
*
* Note: The colors are defined in RGB format r,g,b where r, g and b * define the red, green and blue components of the color. Each of those * must be in the range from 0 to 255.
*/ public class PropertiesSquarenessTheme extends SquarenessTheme { public PropertiesSquarenessTheme (File propertiesFile) throws LoadException { Properties properties = new Properties(); try { properties.load(new FileInputStream(propertiesFile)); processProperties(properties); if (_themeName == null) { _themeName = propertiesFile.getName(); if (_themeName.indexOf('.') > -1) { _themeName = _themeName.substring(0, _themeName.indexOf('.')); } } } catch (IOException e) { e.printStackTrace(); } } public PropertiesSquarenessTheme (Properties properties) throws LoadException { processProperties(properties); } public PropertiesSquarenessTheme(ResourceBundle resourceBundle) throws LoadException { Properties properties = new Properties(); final Enumeration keysEnumeration = resourceBundle.getKeys(); while (keysEnumeration.hasMoreElements()) { String key = (String) resourceBundle.getKeys().nextElement(); properties.put(key, resourceBundle.getString(key)); } processProperties(properties); } /** * Return the name of the theme. */ public String getName () { return _themeName; } public ColorUIResource getDesktopColor () { return _desktopColor; } public ColorUIResource getWindowBackgroundColor () { return _windowBackgroundColor; } public ColorUIResource getInactiveWindowBorderColor () { return _inactiveWindowBorderColor; } public ColorUIResource getNormalBorderColor () { return _normalBorderColor; } public ColorUIResource getDisabledBorderColor () { return _disabledBorderColor; } public ColorUIResource getDefaultButtonBorderColor () { return _defaultButtonBorderColor; } public ColorUIResource getNormalControlBackgroundColor () { return _normalControlBackgroundColor; } public ColorUIResource getSelectedControlBackgroundColor () { return _selectedControlBackgroundColor; } public ColorUIResource getSelectedControlBackgroundShadowColor () { return _selectedControlBackgroundShadowColor; } public ColorUIResource getProgressBarBackgroundColor () { return _progressBarBackgroundColor; } public ColorUIResource getPressedScrollBarTrackBackgroundColor () { return _pressedScrollBarTrackBackgroundColor; } public ColorUIResource getTextInputBackgroundColor () { return _textInputBackgroundColor; } public ColorUIResource getTextColor () { return _textColor; } public boolean isDark () { return _isDark; } private void processProperties(Properties properties) throws LoadException { DefaultSquarenessTheme defaultTheme = new DefaultSquarenessTheme(); _desktopColor = getColor("desktopColor", defaultTheme.getDesktopColor(), properties); _windowBackgroundColor = getColor("windowBackgroundColor", defaultTheme.getWindowBackgroundColor(), properties); _inactiveWindowBorderColor = getColor("inactiveWindowBorderColor", defaultTheme.getInactiveWindowBorderColor(), properties); _normalBorderColor = getColor("normalBorderColor", defaultTheme.getNormalBorderColor(), properties); _disabledBorderColor = getColor("disabledBorderColor", defaultTheme.getDisabledBorderColor(), properties); _defaultButtonBorderColor = getColor("defaultButtonBorderColor", defaultTheme.getDefaultButtonBorderColor(), properties); _normalControlBackgroundColor = getColor("normalControlBackgroundColor", defaultTheme.getNormalControlBackgroundColor(), properties); _selectedControlBackgroundColor = getColor("selectedControlBackgroundColor", defaultTheme.getSelectedControlBackgroundColor(), properties); _selectedControlBackgroundShadowColor = getColor("selectedControlBackgroundShadowColor", defaultTheme.getSelectedControlBackgroundShadowColor(), properties); _progressBarBackgroundColor = getColor("progressBarBackgroundColor", defaultTheme.getProgressBarBackgroundColor(), properties); _pressedScrollBarTrackBackgroundColor = getColor("pressedScrollBarTrackBackgroundColor", defaultTheme.getPressedScrollBarTrackBackgroundColor(), properties); _textInputBackgroundColor = getColor("textInputBackgroundColor", defaultTheme.getTextInputBackgroundColor(), properties); _textColor = getColor("textColor", defaultTheme.getTextColor(), properties); _themeName = properties.getProperty("themeName"); _isDark = Boolean.valueOf(properties.getProperty("isDark", "false")).booleanValue(); } private ColorUIResource getColor(String colorName, ColorUIResource defaultValue, Properties properties) throws LoadException { ColorUIResource result = null; String colorString = properties.getProperty(colorName); if (colorString != null) { StringTokenizer tokenizer = new StringTokenizer(colorString, ",", false); if (tokenizer.countTokens() == 3) { try { final int red = Integer.parseInt((String) tokenizer.nextElement()); final int green = Integer.parseInt((String) tokenizer.nextElement()); final int blue = Integer.parseInt((String) tokenizer.nextElement()); if ( isValidColorComponent(red) && isValidColorComponent(green) && isValidColorComponent(blue)) { result = new ColorUIResource(red, green, blue); } else { throw new LoadException(colorName, "The colordefinition contains one or more wrong color components. " + "A colordefinition looks like \"colornamw=r,g,b\" where r, g and b " + "define the red, green and blue components of the color. Each of those " + "must be in the range from 0 to 255."); } } catch (NumberFormatException e) { throw new LoadException(colorName, "The colordefinition \""+ colorName + " = " + colorString + "\" is incorrect. " + "A colordefinition looks like \"colornamw=r,g,b\" where r, g and b " + "define the red, green and blue components of the color. Each of those " + "must be in the range from 0 to 255."); } } else { throw new LoadException(colorName, "The colordefinition \""+ colorName + " = " + colorString + "\" is incorrect. " + "A colordefinition looks like \"colornamw=r,g,b\" where r, g and b " + "define the red, green and blue components of the color. Each of those " + "must be in the range from 0 to 255."); } } else { result = defaultValue; } return result; } private boolean isValidColorComponent(int colorComponent) { return colorComponent >= 0 && colorComponent <= 255; } private ColorUIResource _desktopColor; private ColorUIResource _windowBackgroundColor; private ColorUIResource _inactiveWindowBorderColor; private ColorUIResource _normalBorderColor; private ColorUIResource _disabledBorderColor; private ColorUIResource _defaultButtonBorderColor; private ColorUIResource _normalControlBackgroundColor; private ColorUIResource _selectedControlBackgroundColor; private ColorUIResource _selectedControlBackgroundShadowColor; private ColorUIResource _progressBarBackgroundColor; private ColorUIResource _pressedScrollBarTrackBackgroundColor; private ColorUIResource _textInputBackgroundColor; private ColorUIResource _textColor; private String _themeName; private boolean _isDark; public static class LoadException extends Exception { /** */ public LoadException (String propertyEntryName, String message) { super("Error on loading property " + propertyEntryName + " : " + message); } } } squareness-2.3.0/source/net/beeger/squareness/theme/SquarenessTheme.java 100644 0 0 24245 10563076303 23657 0 ustar 0 0 /* Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of 'Robert F. Beeger' nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit http://squareness.beeger.net/ for new releases of Squareness Look And Feel and other skins from the Squareness series. */ package net.beeger.squareness.theme; import java.awt.Font; import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.FontUIResource; import javax.swing.plaf.metal.MetalTheme; /** * The common abstract superclass for all Squareness theme classes. */ public abstract class SquarenessTheme extends MetalTheme { public FontUIResource getControlTextFont () { if (_controlTextFont == null) { _controlTextFont = new FontUIResource("Dialog", Font.PLAIN, 11); } return _controlTextFont; } public FontUIResource getMenuTextFont () { if (_menuTextFont == null) { _menuTextFont = new FontUIResource("Dialog", Font.PLAIN, 11); } return _menuTextFont; } public FontUIResource getSubTextFont () { if (_subTextFont == null) { _subTextFont = new FontUIResource("Dialog", Font.PLAIN, 9); } return _subTextFont; } public FontUIResource getSystemTextFont () { if (_systemTextFont == null) { _systemTextFont = new FontUIResource("Dialog", Font.PLAIN, 11); } return _systemTextFont; } public FontUIResource getUserTextFont () { if (_userTextFont == null) { _userTextFont = new FontUIResource("Dialog", Font.PLAIN, 11); } return _userTextFont; } public FontUIResource getWindowTitleFont () { if (_windowTitleFont == null) { _windowTitleFont = new FontUIResource("Dialog", Font.BOLD, 11); } return _windowTitleFont; } /** * Since some applications explicitely use those metal colors, we define them to matching colors * in the Squareness color space. Still some applications may look funny since the Squareness colors have other * meanings and usages than the Metal colors and cannot be mapped totally correctly. * @return The Squarness normal border color */ protected ColorUIResource getPrimary1 () { return getNormalBorderColor(); } /** * Since some applications explicitely use those metal colors, we define them to matching colors * in the Squareness color space. Still some applications may look funny since the Squareness colors have other * meanings and usages than the Metal colors and cannot be mapped totally correctly. * @return The Squarness selected control background color */ protected ColorUIResource getPrimary2 () { return getSelectedControlBackgroundColor(); } /** * Since some applications explicitely use those metal colors, we define them to matching colors * in the Squareness color space. Still some applications may look funny since the Squareness colors have other * meanings and usages than the Metal colors and cannot be mapped totally correctly. * @return The Squarness selected control background color */ protected ColorUIResource getPrimary3 () { return getSelectedControlBackgroundColor(); } /** * Since some applications explicitely use those metal colors, we define them to matching colors * in the Squareness color space. Still some applications may look funny since the Squareness colors have other * meanings and usages than the Metal colors and cannot be mapped totally correctly. * @return The Squarness normal border color */ protected ColorUIResource getSecondary1 () { return getNormalBorderColor(); } /** * Since some applications explicitely use those metal colors, we define them to matching colors * in the Squareness color space. Still some applications may look funny since the Squareness colors have other * meanings and usages than the Metal colors and cannot be mapped totally correctly. * @return The Squarness disabled border color */ protected ColorUIResource getSecondary2 () { return getDisabledBorderColor(); } /** * Since some applications explicitely use those metal colors, we define them to matching colors * in the Squareness color space. Still some applications may look funny since the Squareness colors have other * meanings and usages than the Metal colors and cannot be mapped totally correctly. * @return The Squarness window background color */ protected ColorUIResource getSecondary3 () { return getWindowBackgroundColor(); } /** *Return the desktop color.
*This color is used as the background color of desktop panes.
* @return the desktop color */ public abstract ColorUIResource getDesktopColor(); /** *Return the window background color.
*This color is used as the background color of windows of all sorts.
* @return the window background color */ public abstract ColorUIResource getWindowBackgroundColor(); /** *Return the inactive window border color.
*This color is used for the border of inactive frames.
* @return the inactive window border color */ public abstract ColorUIResource getInactiveWindowBorderColor(); /** *Return the normal border color.
*This color is used for borders of all sorts: control borders, window, menu etc. borders.
* @return the normal border color */ public abstract ColorUIResource getNormalBorderColor(); /** *Return the disabled border color.
*This color is used for borders of all sorts where the component to which the border is applied is disabled.
* @return the disabled border color */ public abstract ColorUIResource getDisabledBorderColor(); /** *Return the default button border color.
*This color is used for the border of default buttons.
* @return the default button border color */ public abstract ColorUIResource getDefaultButtonBorderColor(); /** *Return the normal control background color.
*This color is used for the background of normal unselected and not disabled controls * such as buttons and scroll bar thumbs
* @return the normal control background color */ public abstract ColorUIResource getNormalControlBackgroundColor(); /** *Return the selected control background color.
*This color is used for the background of selected controls and controls over which the mouse pointer hovers.
* @return the selected control background color */ public abstract ColorUIResource getSelectedControlBackgroundColor(); /** *Return the selected control background shadow color.
*This color is used for the shadow in the background of selected controls.
* @return the selected control background shadow color */ public abstract ColorUIResource getSelectedControlBackgroundShadowColor(); /** *Return the progress bar background color.
*This color is used for the background of progress bars and for the tracks of scroll bars.
* @return the progress bar background color */ public abstract ColorUIResource getProgressBarBackgroundColor(); /** *Return the pressed scroll bar track background color.
*This color is used for the background of scroll bar tracks when the track is pressed (i.e. you clicked the left * mouse button while the mouse pointer was over the track have not released it yet.).
* @return the pressed scroll bar track background color */ public abstract ColorUIResource getPressedScrollBarTrackBackgroundColor(); /** *Return the text input background color.
*This color is used for the background of controls where text can be typed in (text fields, text areas etc.)
* @return the text input background color */ public abstract ColorUIResource getTextInputBackgroundColor(); /** *Return the text color.
*All text - no matter where it is printed on - is printed in this color.)
* @return the text color */ public abstract ColorUIResource getTextColor(); /** * Is this theme a dark theme.Common super class for title panes.
*This class is currently subclassed in inner classes in SquarenessInternalFrameUI and SquarenessRootPaneUI. * Those inner classes add the specific details of handling an internal frame viz. a frame.
*/ public abstract class SquarenessTitlePane extends JComponent { /** * Create the title pane and equip it with the frame buttons. */ public SquarenessTitlePane () { _firstUpdate = true; _maximizeIcon = UIManager.getIcon("InternalFrame.maximizeIcon"); _minimizeIcon = UIManager.getIcon("InternalFrame.minimizeIcon"); _closeButton = new FrameButton(); _closeButton.setIcon(UIManager.getIcon("InternalFrame.closeIcon")); _closeButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { close(); } }); _maxButton = new FrameButton(); _maxButton.setIcon(_maximizeIcon); _maxButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { if(isMaximized()) { restore(); } else { maximize(); } } }); _iconifyButton = new FrameButton(); _iconifyButton.setIcon(UIManager.getIcon("InternalFrame.iconifyIcon")); _iconifyButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { iconify(); } }); add(_iconifyButton); add(_maxButton); add(_closeButton); _titleLabel = new JLabel(); _titleLabel.setFont(UIManager.getFont("InternalFrame.titleFont", getLocale())); _titleLabel.setForeground(SquarenessLookAndFeel.getCurrentSquarenessTheme().getTextColor()); add(_titleLabel); setLayout(new SquarenessTitlePaneLayout()); setBackground(SquarenessLookAndFeel.getCurrentSquarenessTheme().getWindowBackgroundColor()); } /** *Update the title pane
*This updates the title, the enabled state of the buttons and the icon on the maximize/restore button.
*/ protected void update() { boolean closeable = isClosable(); boolean iconifiable = isIconifiable(); boolean maximized = isMaximized(); boolean maximizable = isMaximizable(); Font font = UIManager.getFont("InternalFrame.titleFont", getLocale()); String title = getTitle(); if (_firstUpdate || _lastCloseable != closeable) { _closeButton.setEnabled(closeable); } if (_firstUpdate || _lastIconifiable != iconifiable) { _iconifyButton.setEnabled(iconifiable); } if (_firstUpdate || _lastMaximized != maximized) { _maxButton.setIcon(maximized ? _minimizeIcon : _maximizeIcon); } if (_firstUpdate || _lastMaximizable != maximizable) { _maxButton.setEnabled(maximizable); } if (_firstUpdate || !font.equals(_lastFont)) { _titleLabel.setFont(font); } if (_firstUpdate || (title == null && _lastTitle != null) || (title != null && !title.equals(_lastTitle))) { _titleLabel.setText(title); } _lastCloseable = closeable; _lastIconifiable = iconifiable; _lastMaximized = maximized; _lastMaximizable = maximizable; _lastFont = font; _lastTitle = title; _firstUpdate = false; } /** * Do we have a left to right orientation? * * @return True if we are in left to right orientation, false otherwise. */ public abstract boolean isLeftToRight(); protected abstract boolean isIconifiable (); protected abstract boolean isMaximizable (); protected abstract boolean isClosable (); /** * Close the (internal) frame. */ protected abstract void close(); /** * Iconify the (internal) frame. */ protected abstract void iconify(); /** * Maximize the (internal) frame. */ protected abstract void maximize(); /** * Restore the (internal) frame. */ protected abstract void restore(); /** * Can the (internal) frame this title pane belongs to be maximized? * @return true if the (internal) frame can be maximized. */ protected abstract boolean isMaximized(); /** * Can the (internal) frame this title pane belongs to be iconified? * @return true if the (internal) frame can be iconified. */ protected abstract boolean isIconified(); /** * Return the title of the (internal) frame. * @return The title of the (internal) frame. */ protected abstract String getTitle(); private Icon _maximizeIcon; private Icon _minimizeIcon; private JButton _closeButton; private JButton _maxButton; private JButton _iconifyButton; private JLabel _titleLabel; /** * The layout manager of the Squareness title pane. It puts the buttons and the title on their right places. */ protected class SquarenessTitlePaneLayout implements LayoutManager { /** * Removes the specified component from the layout. * * @param comp the component to be removed */ public void removeLayoutComponent (Component comp) { } /** * If the layout manager uses a per-component string, * adds the componentcomp
to the layout,
* associating it
* with the string specified by name
.
*
* @param name the string to be associated with the component
* @param comp the component to be added
*/
public void addLayoutComponent (String name, Component comp)
{
}
/**
* Calculates the minimum size dimensions for the specified
* container, given the components it contains.
*
* @param parent the component to be laid out
* @see #preferredLayoutSize
*/
public Dimension minimumLayoutSize (Container parent)
{
return new Dimension(_closeButton.getIcon().getIconWidth() + 60, _closeButton.getIcon().getIconHeight() + 2);
}
/**
* Calculates the preferred size dimensions for the specified
* container, given the components it contains.
*
* @param parent the container to be laid out
* @see #minimumLayoutSize
*/
public Dimension preferredLayoutSize (Container parent)
{
return minimumLayoutSize(parent);
}
public void layoutContainer (Container container)
{
boolean leftToRight = isLeftToRight();
int width = getWidth();
int height = getHeight();
int x;
int buttonHeight = _closeButton.getIcon().getIconHeight();
int buttonWidth = _closeButton.getIcon().getIconWidth();
int y = (height - buttonHeight) >> 1;
x = (leftToRight) ? width - buttonWidth - 2 : 2;
_closeButton.setBounds(x, y, buttonWidth, buttonHeight);
x += (leftToRight) ? -(buttonWidth + 2) : buttonWidth + 2;
_maxButton.setBounds(x, y, buttonWidth, buttonHeight);
x += (leftToRight) ? -(buttonWidth + 2) : buttonWidth + 2;
_iconifyButton.setBounds(x, y, buttonWidth, buttonHeight);
int maxX = leftToRight ? x - 2 : width - 2;
x = leftToRight ? 2 : x + 2;
_titleLabel.setBounds(x, y, maxX - x, buttonHeight);
}
}
/**
* A convenience class used for the frame buttons.
* Instances of this class have no borders, no margins and are not focusable.
*/
protected static class FrameButton extends JButton
{
/**
* Creates a button with no set text or icon.
*/
public FrameButton ()
{
setMargin(new Insets(0,0,0,0));
setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
setOpaque(true);
setFocusPainted(false);
}
/**
* Returns whether this Component can be focused.
*
* @return true
if this Component is focusable;
* false
otherwise.
* @see #setFocusable
* @since 1.4
*/
public boolean isFocusable ()
{
return false;
}
}
private boolean _lastCloseable;
private boolean _lastIconifiable;
private boolean _lastMaximized;
private boolean _lastMaximizable;
private Font _lastFont;
private String _lastTitle;
private boolean _firstUpdate;
} squareness-2.3.0/source/org/jvnet/lafplugin/ComponentPluginManager.java 100644 0 0 6124 10401612330 23502 0 ustar 0 0 package org.jvnet.lafplugin;
import java.util.Iterator;
import java.util.Set;
import javax.swing.UIDefaults;
/**
* Plugin manager for look-and-feels.
*
* @author Kirill Grouchnikov
* @author Erik Vickroy
* @author Robert Beeger
* @author Frederic Lavigne
* @author Pattrick Gotthardt
*/
public class ComponentPluginManager extends PluginManager {
/**
* Simple constructor.
*
* @param xmlName
* The name of XML file that contains plugin configuration.
* @param mainTag
* The main tag in the XML configuration file.
* @param pluginTag
* The tag that corresponds to a single plugin kind. Specifies
* the plugin kind that will be located in
* {@link #getAvailablePlugins(boolean)}.
*/
public ComponentPluginManager(String xmlName) {
super(xmlName, LafComponentPlugin.TAG_MAIN,
LafComponentPlugin.COMPONENT_TAG_PLUGIN_CLASS);
}
/**
* Helper function to initialize all available component plugins of
* this
plugin manager. Calls the
* {@link LafComponentPlugin#initialize()} of all available component
* plugins.
*/
public void initializeAll() {
Set availablePlugins = this.getAvailablePlugins();
for (Iterator iterator = availablePlugins.iterator(); iterator
.hasNext();) {
Object pluginObject = iterator.next();
if (pluginObject instanceof LafComponentPlugin)
((LafComponentPlugin) pluginObject).initialize();
}
}
/**
* Helper function to uninitialize all available component plugins of
* this
plugin manager. Calls the
* {@link LafComponentPlugin#uninitialize()} of all available component
* plugins.
*/
public void uninitializeAll() {
Set availablePlugins = this.getAvailablePlugins();
for (Iterator iterator = availablePlugins.iterator(); iterator
.hasNext();) {
Object pluginObject = iterator.next();
if (pluginObject instanceof LafComponentPlugin)
((LafComponentPlugin) pluginObject).uninitialize();
}
}
/**
* Helper function to process the (possibly) theme-dependent default
* settings of all available component plugins of this
plugin
* manager. Calls the {@link LafComponentPlugin#getDefaults(Object)} of all
* available plugins and puts the respective results in the specified table.
*
* @param table
* The table that will be updated with the (possibly)
* theme-dependent default settings of all available component
* plugins.
* @param themeInfo
* LAF-specific information on the current theme.
*/
public void processAllDefaultsEntries(UIDefaults table, Object themeInfo) {
Set availablePlugins = this.getAvailablePlugins();
for (Iterator iterator = availablePlugins.iterator(); iterator
.hasNext();) {
Object pluginObject = iterator.next();
if (pluginObject instanceof LafComponentPlugin) {
Object[] defaults = ((LafComponentPlugin) pluginObject)
.getDefaults(themeInfo);
if (defaults != null) {
table.putDefaults(defaults);
}
}
}
}
}
squareness-2.3.0/source/org/jvnet/lafplugin/LafComponentPlugin.java 100644 0 0 2460 10401612724 22640 0 ustar 0 0 package org.jvnet.lafplugin;
import javax.swing.plaf.metal.MetalTheme;
/**
* Basic interface for look-and-feel plugins.
*
* @author Kirill Grouchnikov
* @author Erik Vickroy
* @author Robert Beeger
* @author Frederic Lavigne
* @author Pattrick Gotthardt
*/
public interface LafComponentPlugin extends LafPlugin {
/**
* XML tag for look-and-feel plugins that specify component UI delegates.
*/
public static final String COMPONENT_TAG_PLUGIN_CLASS = "component-plugin-class";
/**
* Initializes this
plugin.
*/
public void initialize();
/**
* Unitializes this
plugin.
*/
public void uninitialize();
/**
* Retrieves a collection of custom settings based on the specified theme.
* The entries in the array should be pairwise, odd being symbolic name of a
* setting, and even being the setting value.
*
* @param themeInfo
* Theme information object. Can be {@link MetalTheme}, for
* instance or any other LAF-specific object.
* @return Collection of custom settings based on the specified theme. The
* entries in the array should be pairwise, odd being symbolic name
* of a setting, and even being the setting value.
*/
public Object[] getDefaults(Object themeInfo);
}
squareness-2.3.0/source/org/jvnet/lafplugin/LafPlugin.java 100644 0 0 652 10401612706 20736 0 ustar 0 0 package org.jvnet.lafplugin;
/**
* Basic interface for look-and-feel plugins.
*
* @author Kirill Grouchnikov
* @author Erik Vickroy
* @author Robert Beeger
* @author Frederic Lavigne
* @author Pattrick Gotthardt
*/
public interface LafPlugin {
/**
* Main XML tag. See
* {@link PluginManager#PluginManager(String, String, String)}.
*/
public static final String TAG_MAIN = "laf-plugin";
}
squareness-2.3.0/source/org/jvnet/lafplugin/LafPlugin.license 100644 0 0 3043 10357023212 21452 0 ustar 0 0 Copyright (c) 2005, Kirill Grouchnikov and Erik Vickroy
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Kirill Grouchnikov and Erik Vickroy nor
the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE. squareness-2.3.0/source/org/jvnet/lafplugin/NanoXML.license 100644 0 0 2005 10356765732 21065 0 ustar 0 0 NanoXML is distributed under the zlib/libpng license, which is OSS
(Open Source Software) compliant.
Copyright ©2000-2002 Marc De Scheemaecker, All Rights Reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such,
and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any
source distribution.
squareness-2.3.0/source/org/jvnet/lafplugin/PluginManager.java 100644 0 0 11600 10401615424 21641 0 ustar 0 0 package org.jvnet.lafplugin;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.swing.UIDefaults;
/**
* Plugin manager for look-and-feels.
*
* @author Kirill Grouchnikov
* @author Erik Vickroy
* @author Robert Beeger
* @author Frederic Lavigne
* @author Pattrick Gotthardt
*/
public class PluginManager {
private String mainTag;
private String pluginTag;
private String xmlName;
private Set plugins;
/**
* Simple constructor.
*
* @param xmlName
* The name of XML file that contains plugin configuration.
* @param mainTag
* The main tag in the XML configuration file.
* @param pluginTag
* The tag that corresponds to a single plugin kind. Specifies
* the plugin kind that will be located in
* {@link #getAvailablePlugins(boolean)}.
*/
public PluginManager(String xmlName, String mainTag, String pluginTag) {
this.xmlName = xmlName;
this.mainTag = mainTag;
this.pluginTag = pluginTag;
this.plugins = null;
}
// protected String getPluginClass(URL pluginUrl) {
// InputStream is = null;
// try {
// DocumentBuilder builder = DocumentBuilderFactory.newInstance()
// .newDocumentBuilder();
// is = pluginUrl.openStream();
// Document doc = builder.parse(is);
// Node root = doc.getFirstChild();
// if (!this.mainTag.equals(root.getNodeName()))
// return null;
// NodeList children = root.getChildNodes();
// for (int i = 0; i < children.getLength(); i++) {
// Node child = children.item(i);
// if (!this.pluginTag.equals(child.getNodeName()))
// continue;
// if (child.getChildNodes().getLength() != 1)
// return null;
// Node text = child.getFirstChild();
// if (text.getNodeType() != Node.TEXT_NODE)
// return null;
// return text.getNodeValue();
// }
// return null;
// } catch (Exception exc) {
// return null;
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (Exception e) {
// }
// }
// }
// }
//
protected String getPluginClass(URL pluginUrl) {
InputStream is = null;
InputStreamReader isr = null;
try {
XMLElement xml = new XMLElement();
is = pluginUrl.openStream();
isr = new InputStreamReader(is);
xml.parseFromReader(isr);
if (!this.mainTag.equals(xml.getName()))
return null;
Enumeration children = xml.enumerateChildren();
while (children.hasMoreElements()) {
XMLElement child = (XMLElement) children.nextElement();
if (!this.pluginTag.equals(child.getName()))
continue;
if (child.countChildren() != 0)
return null;
return child.getContent();
}
return null;
} catch (Exception exc) {
return null;
} finally {
if (isr != null) {
try {
isr.close();
} catch (Exception e) {
}
}
if (is != null) {
try {
is.close();
} catch (Exception e) {
}
}
}
}
protected Object getPlugin(URL pluginUrl) throws Exception {
String pluginClassName = this.getPluginClass(pluginUrl);
if (pluginClassName == null)
return null;
Class pluginClass = Class.forName(pluginClassName);
if (pluginClass == null)
return null;
Object pluginInstance = pluginClass.newInstance();
if (pluginInstance == null)
return null;
return pluginInstance;
}
/**
* Returns a collection of all available plugins.
*
* @return Collection of all available plugins. The classpath is scanned
* only once.
* @see #getAvailablePlugins(boolean)
*/
public Set getAvailablePlugins() {
return this.getAvailablePlugins(false);
}
/**
* Returns a collection of all available plugins. The parameter specifies
* whether the classpath should be rescanned or whether to return the
* already found plugins (after first-time scan).
*
* @param toReload
* If true
, the classpath is scanned for
* available plugins every time this
function is
* called. If false
, the classpath scan is
* performed only once. The consecutive calls return the cached
* result.
* @return Collection of all available plugins.
*/
public Set getAvailablePlugins(boolean toReload) {
if (toReload && (this.plugins != null))
return this.plugins;
this.plugins = new HashSet();
ClassLoader cl = PluginManager.class.getClassLoader();
try {
Enumeration urls = cl.getResources(this.xmlName);
while (urls.hasMoreElements()) {
URL pluginUrl = (URL) urls.nextElement();
Object pluginInstance = this.getPlugin(pluginUrl);
if (pluginInstance != null)
this.plugins.add(pluginInstance);
}
} catch (Exception exc) {
return null;
}
return plugins;
}
}
squareness-2.3.0/source/org/jvnet/lafplugin/XMLElement.java 100644 0 0 276407 10377705472 21143 0 ustar 0 0 /* XMLElement.java
*
* $Revision: 1.4 $
* $Date: 2002/03/24 10:27:59 $
* $Name: RELEASE_2_2_1 $
*
* This file is part of NanoXML 2 Lite.
* Copyright (C) 2000-2002 Marc De Scheemaecker, All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in
* a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*****************************************************************************/
package org.jvnet.lafplugin;
import java.io.ByteArrayOutputStream;
import java.io.CharArrayReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
/**
* XMLElement is a representation of an XML object. The object is able to parse
* XML code.
*
* XMLElement xml = new XMLElement();
* FileReader reader = new FileReader("filename.xml");
* xml.parseFromReader(reader);
*
* XMLElement element = ...;
* Enumeration enum = element.getAttributeNames();
* while (enum.hasMoreElements()) {
* String key = (String) enum.nextElement();
* String value = element.getStringAttribute(key);
* System.out.println(key + " = " + value);
* }
*
* <title>The Title</title>
*
* * @see nanoxml.XMLParseException * * @author Marc De Scheemaecker * <cyberelf@mac.com> * @version $Name: RELEASE_2_2_1 $, $Revision: 1.4 $ */ public class XMLElement { /** * Serialization serial version ID. */ static final long serialVersionUID = 6685035139346394777L; /** * Major version of NanoXML. Classes with the same major and minor * version are binary compatible. Classes with the same major version * are source compatible. If the major version is different, you may * need to modify the client source code. * * @see nanoxml.XMLElement#NANOXML_MINOR_VERSION */ public static final int NANOXML_MAJOR_VERSION = 2; /** * Minor version of NanoXML. Classes with the same major and minor * version are binary compatible. Classes with the same major version * are source compatible. If the major version is different, you may * need to modify the client source code. * * @see nanoxml.XMLElement#NANOXML_MAJOR_VERSION */ public static final int NANOXML_MINOR_VERSION = 2; /** * The attributes given to the element. * *
null
.
* null
.
* XMLElement
* or a subclass of XMLElement
.
* null
iff the element is not
* initialized by either parse or setName.
* null
, it's not empty.
* null
, it contains a valid
* XML identifier.
* null
iff the element is not a
* #PCDATA element.
* null
.
* lineNr >= 0
* true
if the case of the element and attribute names
* are case insensitive.
*/
private boolean ignoreCase;
/**
* true
if the leading and trailing whitespace of #PCDATA
* sections have to be ignored.
*/
private boolean ignoreWhitespace;
/**
* Character read too much.
* This character provides push-back functionality to the input reader
* without having to use a PushbackReader.
* If there is no such character, this field is '\0'.
*/
private char charReadTooMuch;
/**
* The reader provided by the caller of the parse method.
*
* null
while the parse method
* is running.
* new XMLElement(new Hashtable(), false, true)
*
new XMLElement(entities, false, true)
*
entities != null
* new XMLElement(new Hashtable(), skipLeadingWhitespace, true)
*
true
if leading and trailing whitespace in PCDATA
* content has to be removed.
*
* new XMLElement(entities, skipLeadingWhitespace, true)
*
true
if leading and trailing whitespace in PCDATA
* content has to be removed.
*
* entities != null
* true
if leading and trailing whitespace in PCDATA
* content has to be removed.
* @param ignoreCase
* true
if the case of element and attribute names have
* to be ignored.
*
* entities != null
*
* This constructor should only be called from
* {@link #createAnotherElement() createAnotherElement}
* to create child elements.
*
* @param entities
* The entity conversion table.
* @param skipLeadingWhitespace
* true
if leading and trailing whitespace in PCDATA
* content has to be removed.
* @param fillBasicConversionTable
* true
if the basic entities need to be added to
* the entity list.
* @param ignoreCase
* true
if the case of element and attribute names have
* to be ignored.
*
*
entities != null
* fillBasicConversionTable == false
* then entities
contains at least the following
* entries: amp
, lt
, gt
,
* apos
and quot
* child != null
* child.getName() != null
* child
does not have a parent element
* name != null
* name
is a valid XML identifier
* value != null
* name != null
* name
is a valid XML identifier
* name != null
* name
is a valid XML identifier
* result >= 0
* result != null
* result != null
* result != null
* null
is returned.
*
* @deprecated Use {@link #getContent() getContent} instead.
*/
public String getContents()
{
return this.getContent();
}
/**
* Returns the PCDATA content of the object. If there is no such content,
* null
is returned.
*
* @see nanoxml.XMLElement#setContent(java.lang.String)
* setContent(String)
*/
public String getContent()
{
return this.contents;
}
/**
* Returns the line nr in the source data on which the element is found.
* This method returns 0
there is no associated source data.
*
* result >= 0
* null
is returned.
*
* @param name The name of the attribute.
*
* name != null
* name
is a valid XML identifier
* defaultValue
is returned.
*
* @param name The name of the attribute.
* @param defaultValue Key to use if the attribute is missing.
*
* name != null
* name
is a valid XML identifier
*
* As an example, if valueSet contains the mapping "one" =>
* "1"
* and the element contains the attribute attr="one"
, then
* getAttribute("attr", mapping, defaultKey, false)
returns
* "1"
.
*
* @param name
* The name of the attribute.
* @param valueSet
* Hashtable mapping keys to values.
* @param defaultKey
* Key to use if the attribute is missing.
* @param allowLiterals
* true
if literals are valid.
*
*
name != null
* name
is a valid XML identifier
* valueSet
!= null
* valueSet
are strings
* null
is returned.
*
* @param name The name of the attribute.
*
* name != null
* name
is a valid XML identifier
* defaultValue
is returned.
*
* @param name The name of the attribute.
* @param defaultValue Key to use if the attribute is missing.
*
* name != null
* name
is a valid XML identifier
*
* As an example, if valueSet contains the mapping "one" =>
* "1"
* and the element contains the attribute attr="one"
, then
* getAttribute("attr", mapping, defaultKey, false)
returns
* "1"
.
*
* @param name
* The name of the attribute.
* @param valueSet
* Hashtable mapping keys to values.
* @param defaultKey
* Key to use if the attribute is missing.
* @param allowLiterals
* true
if literals are valid.
*
*
name != null
* name
is a valid XML identifier
* valueSet
!= null
* valueSet
are strings
* valueSet
are strings
* 0
is returned.
*
* @param name The name of the attribute.
*
* name != null
* name
is a valid XML identifier
* defaultValue
is returned.
*
* @param name The name of the attribute.
* @param defaultValue Key to use if the attribute is missing.
*
* name != null
* name
is a valid XML identifier
*
* As an example, if valueSet contains the mapping "one" => 1
* and the element contains the attribute attr="one"
, then
* getIntAttribute("attr", mapping, defaultKey, false)
returns
* 1
.
*
* @param name
* The name of the attribute.
* @param valueSet
* Hashtable mapping keys to values.
* @param defaultKey
* Key to use if the attribute is missing.
* @param allowLiteralNumbers
* true
if literal numbers are valid.
*
*
name != null
* name
is a valid XML identifier
* valueSet
!= null
* valueSet
are strings
* valueSet
are Integer objects
* defaultKey
is either null
, a
* key in valueSet
or an integer.
* 0.0
is returned.
*
* @param name The name of the attribute.
*
* name != null
* name
is a valid XML identifier
* defaultValue
is returned.
*
* @param name The name of the attribute.
* @param defaultValue Key to use if the attribute is missing.
*
* name != null
* name
is a valid XML identifier
*
* As an example, if valueSet contains the mapping "one" =>
* 1.0
* and the element contains the attribute attr="one"
, then
* getDoubleAttribute("attr", mapping, defaultKey, false)
* returns 1.0
.
*
* @param name
* The name of the attribute.
* @param valueSet
* Hashtable mapping keys to values.
* @param defaultKey
* Key to use if the attribute is missing.
* @param allowLiteralNumbers
* true
if literal numbers are valid.
*
*
name != null
* name
is a valid XML identifier
* valueSet != null
* valueSet
are strings
* valueSet
are Double objects
* defaultKey
is either null
, a
* key in valueSet
or a double.
* defaultValue
is returned.
* If the value of the attribute is equal to trueValue
,
* true
is returned.
* If the value of the attribute is equal to falseValue
,
* false
is returned.
* If the value doesn't match trueValue
or
* falseValue
, an exception is thrown.
*
* @param name The name of the attribute.
* @param trueValue The value associated with true
.
* @param falseValue The value associated with true
.
* @param defaultValue Value to use if the attribute is missing.
*
* name != null
* name
is a valid XML identifier
* trueValue
and falseValue
* are different strings.
* reader != null
* reader
is not closed
* reader != null
* reader
is not closed
* string != null
* string.length() > 0
* string
to scan.
*
* string != null
* offset < string.length()
* offset >= 0
* string
to scan.
* @param end
* The character where to stop scanning.
* This character is not scanned.
*
* string != null
* end <= string.length()
* offset < end
* offset >= 0
* string
to scan.
* @param end
* The character where to stop scanning.
* This character is not scanned.
* @param startingLineNr
* The line number of the first line in the data.
*
* string != null
* end <= string.length()
* offset < end
* offset >= 0
* string
to scan.
* @param end
* The character where to stop scanning.
* This character is not scanned.
*
* input != null
* end <= input.length
* offset < end
* offset >= 0
* string
to scan.
* @param end
* The character where to stop scanning.
* This character is not scanned.
* @param startingLineNr
* The line number of the first line in the data.
*
* input != null
* end <= input.length
* offset < end
* offset >= 0
* child != null
* child
is a child element of the receiver
* name != null
* name
is a valid XML identifier
* null
* * You should override this method when subclassing XMLElement. */ protected XMLElement createAnotherElement() { return new XMLElement(this.entities, this.ignoreWhitespace, false, this.ignoreCase); } /** * Changes the content string. * * @param content * The new content string. */ public void setContent(String content) { this.contents = content; } /** * Changes the name of the element. * * @param name * The new name. * * @deprecated Use {@link #setName(java.lang.String) setName} instead. */ public void setTagName(String name) { this.setName(name); } /** * Changes the name of the element. * * @param name * The new name. * *
name != null
* name
is a valid XML identifier
* writer != null
* writer
is not closed
* writer != null
* writer
is not closed
* str != null
* result
.
*
* @param result
* The buffer in which the scanned identifier will be put.
*
* result != null
* result
.
*
* @return the next character following the whitespace.
*
* result != null
* string
.
*
* string != null
* data
.
*
* data != null
* buf
.
*
* buf != null
* bracketLevel >= 0
* literal != null
* elt != null
* buf
.
*
* @param buf Where to put the entity value.
*
* buf != null
* ch != '\0'
* name != null
* name != null
* value != null
* context != null
* context.length() > 0
* charSet != null
* charSet.length() > 0
* name != null
* name.length() > 0
*
* $Revision: 1.4 $
* $Date: 2002/03/24 10:27:59 $
*
* @see nanoxml.XMLElement
*
* @author Marc De Scheemaecker
* @version $Name: RELEASE_2_2_1 $, $Revision: 1.4 $
*/
public class XMLParseException
extends RuntimeException
{
/**
* Indicates that no line number has been associated with this exception.
*/
public static final int NO_LINE = -1;
/**
* The line number in the source code where the error occurred, or
* NO_LINE
if the line number is unknown.
*
*
lineNr > 0 || lineNr == NO_LINE
* message != null
* message != null
* lineNr > 0
* NO_LINE
if the line number is
* unknown.
*
* @see nanoxml.XMLParseException#NO_LINE
*/
public int getLineNr()
{
return this.lineNr;
}
}
squareness-2.3.0/license/squareness_license.txt 100644 0 0 3076 10531616535 17125 0 ustar 0 0 Copyright (c) 2003-2006, Robert F. Beeger (robert at beeger dot net)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of 'Robert F. Beeger' nor the names of his contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data reached";
return new XMLParseException(this.getName(), this.parserLineNr, msg);
}
/**
* Creates a parse exception for when a syntax error occured.
*
* @param context The context in which the error occured.
*
* context != null
* context.length() > 0
* charSet != null
* charSet.length() >