Skip to content

Instantly share code, notes, and snippets.

@keiono
Created April 2, 2012 18:21
Show Gist options
  • Save keiono/2286021 to your computer and use it in GitHub Desktop.
Save keiono/2286021 to your computer and use it in GitHub Desktop.
Visual Property Dependency New API Plan 1
/**
*
* Plan 1: Use existing VisualLexicon Tree as is.
*
* Set of Visual Properties which are dependent to each other
*
* All Visual Properties should have save data type T.
*
*/
public interface VisualPropertyDependency<T> {
/**
* Provides human-readable name of this dependency.
* For example, "Synchronize edge color to arrow head color,"
* or "Fit Custom Graphics to node"
*
* @return name of this dependency.
*/
String getDisplayName();
/**
* A set of Visual Properties to be set by the parent if locked.
*
* @return set of visual properties to be set by parent value.
*/
Set<VisualProperty<T>> getVisualProperties();
}
package org.cytoscape.view.vizmap;
import java.util.Collection;
import java.util.Set;
import org.cytoscape.model.CyIdentifiable;
import org.cytoscape.view.model.View;
import org.cytoscape.view.model.VisualProperty;
/**
* A VisualStyle is a collection of {@linkplain VisualMappingFunction}s and default values
* that define how a set of attributes is mapped to visual properties of View objects.
* @CyAPI.Api.Interface
*/
public interface VisualStyle {
/**
* Returns name of this visual style. This should NOT be used as the ID of this
* Visual Style. Just for GUI components and may not be unique.
*
* <p>
* Title of Visual Style is a mutable field and may <strong>NOT</strong> be unique.
*
* @return title of this visual style
*/
String getTitle();
/**
* Set new title for this VisualStyle.
*
* @param title New title of this VisualStyle.
*/
void setTitle(final String title);
/**
* Add a new {@linkplain VisualMappingFunction} to this VisualStyle.
*
* @param mapping new VisualMappingFunction to be added.
*/
void addVisualMappingFunction(final VisualMappingFunction<?, ?> mapping);
/**
* Remove a VisualMappingFunction for the VisualProperty.
* One visual property can be associated with only one mapping function,
* so this always removes correct one.
*
* @param vp VisualMappingFunction associated with this VisualProperty will be removed.
*
*/
void removeVisualMappingFunction(final VisualProperty<?> vp);
/**
* Get current {@linkplain VisualMappingFunction} for the VisualProperty.
*
* @param <V> Data type of VisualProperty.
*
* @param vp visual property associated with the target mapping.
*
* @return mapping function for the VisualProperty. If no mapping is available, this value is null.
*
*/
<V> VisualMappingFunction<?, V> getVisualMappingFunction(final VisualProperty<V> vp);
/**
* Returns all {@linkplain VisualMappingFunction}s in this style.
*
* @return All mappings for this style.
*/
Collection<VisualMappingFunction<?, ?>> getAllVisualMappingFunctions();
/**
* Returns default value for the VisualProperty.
* This is style's default value, not same as VisualProperty default.
* If VisualMappingFunction is not available for this VisualProperty, this default value will be used in the view model.
*
* @param <V> Data type of VisualProperty
*
* @param vp target VisualProperty
*
* @return Style's default value for the VisualProperty.
*/
<V> V getDefaultValue(final VisualProperty<V> vp);
/**
* Set default value for the VisualProperty.
*
* @param <V> Data type of VisualProperty
* @param <S> Data type of actual default value. This can be same as V or its child classes.
*
* @param vp target VisualProperty
* @param value Value to be set as default. This can be child type of V. For example,
* if V is Number, S can be Double, Integer, etc.
*/
<V, S extends V> void setDefaultValue(final VisualProperty<V> vp, final S value);
/**
* Apply visual only to a individual View Object (node/edge),
* not the entire network view.
*
* @param View object to be updated
*/
void apply(final View<? extends CyIdentifiable> view);
/**
* Get all dependencies for this style.
*
* @return set of dependencies associated with this style.
*/
Set<VisualPropertyDependency<?>> getVisualPropertyDependencies();
/**
* Add a new VisualPropertyDependency.
*
* @param dependency new dependency to be added
*/
void addVisualPropertyDependency(final Set<VisualPropertyDependency<?>> dependency);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment