org.flexdock.plaf.PropertySet Maven / Gradle / Ivy
/*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.flexdock.plaf;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.border.Border;
/**
* @author Christopher Butler
*/
public class PropertySet {
private HashMap properties;
private String name;
public PropertySet() {
properties = new HashMap();
}
public PropertySet(int size) {
properties = new HashMap(size);
}
public void setAll(PropertySet set) {
if(set!=null) {
properties.putAll(set.properties);
}
}
public void setProperty(String key, Object value) {
properties.put(key, value);
}
public Object getProperty(String key) {
return properties.get(key);
}
public Color getColor(String key) {
Object property = getProperty(key);
return property instanceof Color? (Color)property: null;
}
public Font getFont(String key) {
Object property = getProperty(key);
return property instanceof Font? (Font)property: null;
}
public Image getImage(String key) {
Object property = getProperty(key);
return property instanceof Image? (Image)property: null;
}
public Icon getIcon(String key) {
Object property = getProperty(key);
return property instanceof Icon? (Icon)property: null;
}
public Action getAction(String key) {
Object property = getProperty(key);
return property instanceof Action? (Action)property: null;
}
public String getString(String key) {
Object property = getProperty(key);
return property instanceof String? (String)property: null;
}
public Border getBorder(String key) {
Object property = getProperty(key);
return property instanceof Border? (Border)property: null;
}
public String[] getStrings(String[] keys) {
if(keys==null) {
return null;
}
String[] values = new String[keys.length];
for(int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy