// PathVisio,
// a tool for data visualization and analysis using Biological Pathways
// Copyright 2006-2011 BiGCaT Bioinformatics
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.pathvisio.gui.handler;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.bridgedb.bio.Organism;
import org.pathvisio.core.debug.Logger;
import org.pathvisio.core.model.AlignType;
import org.pathvisio.core.model.CellularComponentType;
import org.pathvisio.core.model.DataNodeType;
import org.pathvisio.core.model.GroupStyle;
import org.pathvisio.core.model.LineStyle;
import org.pathvisio.core.model.LineType;
import org.pathvisio.core.model.ObjectType;
import org.pathvisio.core.model.OrientationType;
import org.pathvisio.core.model.PathwayElement;
import org.pathvisio.core.model.Property;
import org.pathvisio.core.model.PropertyManager;
import org.pathvisio.core.model.PropertyType;
import org.pathvisio.core.model.ShapeType;
import org.pathvisio.core.model.StaticProperty;
import org.pathvisio.core.model.StaticPropertyType;
import org.pathvisio.core.model.ValignType;
import org.pathvisio.core.preferences.GlobalPreference;
import org.pathvisio.core.preferences.Preference;
import org.pathvisio.core.preferences.PreferenceManager;
/**
* This class manages how properties should be displayed. It keeps track of TypeHandlers, which properties should be
* visible, and the order in which properties should be displayed.
*
* The main entry point for plugins are {@link #registerProperty(Property)} and
* {@link #registerTypeHandler(TypeHandler)}.
*
* @author Mark Woon
*/
public class PropertyDisplayManager {
private static final Map TYPE_HANDLERS = new HashMap();
private static final Map PROPERTY_PREFERENCES = new HashMap();
private static final Map DYNAMIC_PROPERTIES = new HashMap();
private static final Set MANAGED_DYNAMIC_PROPERTIES = new HashSet();
private static final Map> PROPERTY_SCOPE = new HashMap>();
private static boolean STORE_PREFERENCES = false;
static {
PreferenceManager.init();
// register core property types
registerTypeHandler(new BooleanHandler());
registerTypeHandler(NumberHandler.buildHandler(StaticPropertyType.DOUBLE, Double.class));
registerTypeHandler(NumberHandler.buildHandler(StaticPropertyType.INTEGER, Integer.class));
registerTypeHandler(new AngleHandler());
registerTypeHandler(new ColorHandler());
registerTypeHandler(new CommentsHandler());
registerTypeHandler(new DataSourceHandler());
registerTypeHandler(new FontHandler());
registerTypeHandler(new ComboHandler(StaticPropertyType.GENETYPE, DataNodeType.getNames(), false));
registerTypeHandler(new ComboHandler(StaticPropertyType.GROUPSTYLETYPE, GroupStyle.getNames(), false));
registerTypeHandler(new ComboHandler(StaticPropertyType.LINESTYLE, LineStyle.getNames(), true));
registerTypeHandler(new ComboHandler(StaticPropertyType.LINETYPE, LineType.getVisibleNames(), LineType.getVisibleValues()));
registerTypeHandler(new ComboHandler(StaticPropertyType.ORGANISM, Organism.latinNames(), false));
registerTypeHandler(new ComboHandler(StaticPropertyType.ORIENTATION, OrientationType.getNames(), true));
registerTypeHandler(new ComboHandler(StaticPropertyType.SHAPETYPE, ShapeType.getVisibleNames(), ShapeType.getVisibleValues()));
registerTypeHandler(new ComboHandler(StaticPropertyType.VALIGNTYPE, ValignType.getNames(), ValignType.values()));
registerTypeHandler(new ComboHandler(StaticPropertyType.ALIGNTYPE, AlignType.getNames(), AlignType.values()));
registerTypeHandler(new ComboHandler(CellularComponentType.CELL_COMPONENT_TYPE, CellularComponentType.getNames(), false));
// register core properties
for (StaticProperty p : StaticProperty.values()) {
registerProperty(p);
}
//Register specific dynamic property
//TODO: refactor as Static Property with next GPML update
registerProperty(CellularComponentType.CELL_COMPONENT_PROPERTY);
setPropertyScope(
CellularComponentType.CELL_COMPONENT_PROPERTY,
EnumSet.of(ObjectType.SHAPE)
);
}
/**
* Private constructor - not meant to be instantiated.
*/
private PropertyDisplayManager() {
}
/**
* Gets the visible property keys for the given PathwayElement.
*/
public static Set