⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 visualitem.java

📁 用applet实现很多应用小程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package prefuse.visual;

import java.awt.BasicStroke;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;

import prefuse.Visualization;
import prefuse.data.Schema;
import prefuse.data.Tuple;
import prefuse.data.tuple.TupleSet;
import prefuse.render.Renderer;
import prefuse.util.PrefuseLib;

/**
 * <p>Base interface for representing a visual item, a data object with a
 * visual interactive form. VisualItems are Tuple instances, and so
 * can support any number of data fields in a backing data table. VisualItems
 * also support data fields specific to visualization, such as a location,
 * bounding box, colors, size, and font. The VisualItem interface provides
 * convenience methods for accessing these common visual properties, but
 * the underlying mechanism is the same as any Tuple -- data stored in
 * a tabular format. Just as all Tuple instances are backed by a data Table,
 * each VisualItem is backed by a VisualTable. Additionally, each VisualItem
 * is associated with one and only one {@link prefuse.Visualization}.</p>
 * 
 * <p>VisualItems are only responsible for storing their visual data
 * properties. The final visual appearance of an item is determined by
 * a {@link prefuse.render.Renderer}, which contains instructions for drawing
 * the item. The Renderer to use for a given item is decided by the
 * {@link prefuse.render.RendererFactory} associated with the item's
 * backing Visualization.</p>
 * 
 * <p>Finally, actually setting the visual properties of VisualItems is
 * commonly done by the many {@link prefuse.action.Action} modules available
 * for processing visual data. This includes spatial layout as well as
 * color, size, and font assignment.</p> 
 * 
 * @author <a href="http://jheer.org">jeffrey heer</a>
 */
public interface VisualItem extends Tuple {

    /**
     * Get the backing Visualization of which this VisualItem is a part.
     * @return the backing Visualization
     */
    public Visualization getVisualization();
    
    /**
     * Get the primary data group of which this VisualItem is a member.
     * Returns the name of the group of this item's backing VisualTable.
     * @return the item's primary group
     */
    public String getGroup();
    
    /**
     * Indicates if this item is a member of a given group. This includes both
     * the item's primary group (that of it's backing VisualTable) and any
     * number of additional focus groups associated with the Visualization.
     * @param group the group to check for membership.
     * @return true if this item is in the group, false otherwise.
     */
    public boolean isInGroup(String group);
    
    /**
     * Returns the original backing data set from which this VisualItem is
     * derived. This could be a Table, Graph, or Tree instance. This method
     * returns null if this VisualItem is not derived from backing data.
     * @return the backing data set from which this VisualItem is derived,
     * or null if none.
     */
    public TupleSet getSourceData();

    /**
     * Returns the original backing data tuple from which this VisualItem is
     * derived. This could be a Tuple, Node, or Edge instance. This method
     * returns null if this VisualItem is not derived from backing data.
     * @return the backing data tuple from which this VisualItem is derived,
     * or null if none.
     */
    public Tuple getSourceTuple();
    
    
    // ------------------------------------------------------------------------
    // VisualItem Methods
    
    /**
     * Render this item to the given graphics context. This is typically done
     * by requesting the appropriate Renderer from the backing Visualization's
     * RendererFactory, and then using the Renderer to draw this item.
     * @param g the graphics context to render into.
     */
    public void render(Graphics2D g);
    
    /**
     * Get the Renderer instance for drawing this VisualItem. The Renderer is
     * retrieved by requesting it from the backing Visualization's
     * RendererFactory.
     * @return the Renderer for this VisualItem
     */
    public Renderer getRenderer();
    
    /**
     * Validate the bounds of this VisualItem. When a data value for a
     * VisualItem is updated, it's bounds are invalidated, as the data change
     * may have changed to appearance of the item. Revalidating the bounds
     * causes the bounds of the item to be recomputed and made current.
     * @return the validated boundig box of this item
     */
    public Rectangle2D validateBounds();
    
    // -- Boolean Flags -------------------------------------------------------
      
    /**
     * Indicates if this VisualItem is currently validated. If not,
     * validateBounds() must be run to update the bounds to a current value.
     * @return true if validated, false otherwise
     * @see #VALIDATED
     */
    public boolean isValidated();
    
    /**
     * Set this item's validated flag. This is for internal use by prefuse and,
     * in general, should not be called by application code.
     * @param value the value of the validated flag to set.
     * @see #VALIDATED
     */
    public void setValidated(boolean value);
    
    /**
     * Indicates if this VisualItem is currently set to be visible. Items with
     * the visible flag set false will not be drawn by a display. Invisible
     * items are also by necessity not interactive, regardless of the value of
     * the interactive flag.
     * @return true if visible, false if invisible
     * @see #VISIBLE
     */
    public boolean isVisible();
    
    /**
     * Set this item's visibility.
     * @param value true to make the item visible, false otherwise.
     * @see #VISIBLE
     */
    public void setVisible(boolean value);
    
    /**
     * Indicates if the start visible flag is set to true. This is the
     * visibility value consulted for the staring value of the visibility
     * field at the beginning of an animated transition.
     * @return true if this item starts out visible, false otherwise.
     * @see #STARTVISIBLE
     */
    public boolean isStartVisible();
    
    /**
     * Set the start visible flag.
     * @param value true to set the start visible flag, false otherwise
     * @see #STARTVISIBLE
     */
    public void setStartVisible(boolean value);

    /**
     * Indictes if the end visible flag is set to true. This is the
     * visibility value consulted for the ending value of the visibility
     * field at the end of an animated transition.
     * @return true if this items ends visible, false otherwise.
     * @see #ENDVISIBLE
     */
    public boolean isEndVisible();
    
    /**
     * Set the end visible flag.
     * @param value true to set the end visible flag, false otherwise
     * @see #ENDVISIBLE
     */
    public void setEndVisible(boolean value);
    
    /**
     * Indicates if this item is interactive, meaning it can potentially
     * respond to mouse and keyboard input events.
     * @return true if the item is interactive, false otherwise
     * @see #INTERACTIVE
     */
    public boolean isInteractive();

    /**
     * Set the interactive status of this VisualItem.
     * @param value true for interactive, false for non-interactive
     * @see #INTERACTIVE
     */
    public void setInteractive(boolean value);
    
    /**
     * Indicates this item is expanded. Only used for items that are
     * part of a graph structure. 
     * @return true if expanded, false otherwise
     * @see #EXPANDED
     */
    public boolean isExpanded();

    /**
     * Set the expanded flag.
     * @param value true to set as expanded, false as collapsed.
     * @see #EXPANDED
     */
    public void setExpanded(boolean value);
    
    /**
     * Indicates if the item is fixed, and so will not have its position
     * changed by any layout or distortion actions.
     * @return true if the item has a fixed position, false otherwise
     * @see #FIXED
     */
    public boolean isFixed();

    /**
     * Sets if the item is fixed in its position.
     * @param value true to fix the item, false otherwise
     * @see #FIXED
     */
    public void setFixed(boolean value);
    
    /**
     * Indicates if the item is highlighted.
     * @return true for highlighted, false for not highlighted
     * @see #HIGHLIGHT
     */
    public boolean isHighlighted();
    
    /**
     * Set the highlighted status of this item. How higlighting values are
     * interpreted by the system depends on the various processing actions
     * set up for an application (e.g., how a
     * {@link prefuse.action.assignment.ColorAction} might assign colors
     * based on the flag).
     * @param value true to highlight the item, false for no highlighting.
     * @see #HIGHLIGHT
     */
    public void setHighlighted(boolean value);

    /**
     * Indicates if the item currently has the mouse pointer over it.
     * @return true if the mouse pointer is over this item, false otherwise
     * @see #HOVER
     */
    public boolean isHover();
    
    /**
     * Set the hover flag. This is set automatically by the prefuse framework,
     * so should not need to be set explicitly by application code.
     * @param value true to set the hover flag, false otherwise
     * @see #HOVER
     */
    public void setHover(boolean value);
    
    // ------------------------------------------------------------------------
    
    /**
     * Get the current x-coordinate of this item.
     * @return the current x-coordinate
     * @see #X
     */
    public double getX();

    /**
     * Set the current x-coordinate of this item.
     * @param x the new current x-coordinate
     * @see #X
     */
    public void setX(double x);
    
    /**
     * Get the current y-coordinate of this item.
     * @return the current y-coordinate
     * @see #Y
     */
    public double getY();
    
    /**
     * Set the current y-coordinate of this item.
     * @param y the new current y-coordinate
     * @see #Y
     */
    public void setY(double y);
    
    /**
     * Get the starting x-coordinate of this item.
     * @return the starting x-coordinate
     * @see #STARTX
     */
    public double getStartX();
    
    /**
     * Set the starting x-coordinate of this item.
     * @param x the new starting x-coordinate
     * @see #STARTX
     */
    public void setStartX(double x);
    
    /**
     * Get the starting y-coordinate of this item.
     * @return the starting y-coordinate
     * @see #STARTY
     */
    public double getStartY();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -