001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.visual.laf;
042:
043: import org.netbeans.api.visual.border.Border;
044: import org.netbeans.api.visual.border.BorderFactory;
045: import org.netbeans.api.visual.model.ObjectState;
046: import org.netbeans.api.visual.laf.LookFeel;
047:
048: import java.awt.*;
049:
050: /**
051: * @author David Kaspar
052: */
053: public class DefaultLookFeel extends LookFeel {
054:
055: private static final Color COLOR_SELECTED = new Color(0x447BCD);
056: private static final Color COLOR_HIGHLIGHTED = COLOR_SELECTED
057: .darker();
058: private static final Color COLOR_HOVERED = COLOR_SELECTED
059: .brighter();
060: private static final int MARGIN = 3;
061: private static final int ARC = 10;
062: private static final int MINI_THICKNESS = 1;
063:
064: private static final Border BORDER_NORMAL = BorderFactory
065: .createEmptyBorder(MARGIN, MARGIN);
066: private static final Border BORDER_HOVERED = BorderFactory
067: .createRoundedBorder(ARC, ARC, MARGIN, MARGIN,
068: COLOR_HOVERED, COLOR_HOVERED.darker());
069: private static final Border BORDER_SELECTED = BorderFactory
070: .createRoundedBorder(ARC, ARC, MARGIN, MARGIN,
071: COLOR_SELECTED, COLOR_SELECTED.darker());
072:
073: private static final Border MINI_BORDER_NORMAL = BorderFactory
074: .createEmptyBorder(MINI_THICKNESS);
075: private static final Border MINI_BORDER_HOVERED = BorderFactory
076: .createRoundedBorder(MINI_THICKNESS, MINI_THICKNESS,
077: MINI_THICKNESS, MINI_THICKNESS, COLOR_HOVERED,
078: COLOR_HOVERED.darker());
079: private static final Border MINI_BORDER_SELECTED = BorderFactory
080: .createRoundedBorder(MINI_THICKNESS, MINI_THICKNESS,
081: MINI_THICKNESS, MINI_THICKNESS, COLOR_SELECTED,
082: COLOR_SELECTED.darker());
083:
084: public Paint getBackground() {
085: return Color.WHITE;
086: }
087:
088: public Color getForeground() {
089: return Color.BLACK;
090: }
091:
092: public Border getBorder(ObjectState state) {
093: if (state.isHovered())
094: return BORDER_HOVERED;
095: if (state.isSelected())
096: return BORDER_SELECTED;
097: if (state.isFocused())
098: return BORDER_HOVERED;
099: return BORDER_NORMAL;
100: }
101:
102: public Border getMiniBorder(ObjectState state) {
103: if (state.isHovered())
104: return MINI_BORDER_HOVERED;
105: if (state.isSelected())
106: return MINI_BORDER_SELECTED;
107: if (state.isFocused())
108: return MINI_BORDER_HOVERED;
109: return MINI_BORDER_NORMAL;
110: }
111:
112: public boolean getOpaque(ObjectState state) {
113: return state.isHovered() || state.isSelected();
114: }
115:
116: public Color getLineColor(ObjectState state) {
117: if (state.isHovered())
118: return COLOR_HOVERED;
119: if (state.isSelected())
120: return COLOR_SELECTED;
121: if (state.isHighlighted() || state.isFocused())
122: return COLOR_HIGHLIGHTED;
123: return Color.BLACK;
124: }
125:
126: public Paint getBackground(ObjectState state) {
127: if (state.isHovered())
128: return COLOR_HOVERED;
129: if (state.isSelected())
130: return COLOR_SELECTED;
131: if (state.isHighlighted() || state.isFocused())
132: return COLOR_HIGHLIGHTED;
133: return Color.WHITE;
134: }
135:
136: public Color getForeground(ObjectState state) {
137: return state.isSelected() ? Color.WHITE : Color.BLACK;
138: }
139:
140: public int getMargin() {
141: return MARGIN;
142: }
143:
144: }
|