Documentation of 'kcl.waterloo.graphics.plots2D.GJComponentPlot' Java class
GJComponentPlot
kcl.waterloo.graphics.plots2D

Class GJComponentPlot

  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.util.EventListener, GJEffectorInterface, GJFastPlotInterface, GJPlotInterface, GJLinkableInterface, GJObservableInterface, GJDataModelInterface<java.awt.geom.Rectangle2D,GJGraphInterface>, GJFillableInterface<java.awt.Shape,java.awt.Paint>, GJScreenDataInterface<java.awt.Shape>, GJVisualsInterface<GJMarker,java.awt.Paint,java.awt.BasicStroke,java.awt.Dimension,java.awt.Shape>


    public class GJComponentPlot
    extends GJAbstractPlot
    GJComponentPlot is an exception to the norm. Instead of plotting data, GJComponentPlot adds Swing JComponents to the graph at the locations specified in XData and YData - JLabels, JButtons, even JPanels with web pages in them if you really want to. As graph objects use a SpringLayout, the preferred size property of the added components can be used to control their size. They will be centered on the point defined in XData and YData (horizontally and vertically). Effectively, GJComponentPlot creates a scatter plot where each point is represented by a Swing component. These components are programmable just as they would be in any GUI so you can use them to allow a high level of user-interaction with the graph.

    This code is part of the Waterloo Scientific Graphics package from King's College London

    • Constructor Detail

      • GJComponentPlot

        public GJComponentPlot()
    • Method Detail

      • setComponentsVisible

        public void setComponentsVisible(boolean flag)
      • getComponentArray

        public java.util.ArrayList<javax.swing.JComponent> getComponentArray()
      • setComponentArray

        public final void setComponentArray(java.util.ArrayList<javax.swing.JComponent> c)
      • getComponent

        public final javax.swing.JComponent getComponent(int index)
      • setPreferredSize

        public final void setPreferredSize(int width,
                                           int height)
      • getPreferredSize

        public final java.util.ArrayList<java.awt.Dimension> getPreferredSize()
      • setPreferredSize

        public final void setPreferredSize(java.util.ArrayList<java.awt.Dimension> arr)
      • setComponents

        public void setComponents(javax.swing.JComponent c)
      • setComponents

        public final void setComponents(java.lang.Class clzz)
      • removeComponents

        public void removeComponents()
        Removes all components associated with this plot from the graph
      • paintPlot

        public void paintPlot(java.awt.Graphics2D g2)
        This paintPlot for does NOT do any painting. Instead it calls the add method of the parent graph and places swing components at the required locations. These will become children of the graph, which is a JComponent itself and will therefore be painted as normal from the paintChildren method of the graph. The components need be added only once i.e. the first call to paintPlot. The upToDate flag is used to control this. upToDate should be set false when the data are first added to the plot. Adding the components to the graph in this way allows us to construct a plot with "orphan" JComponents so it behaves in the same way as other plot types rather than being linked to a parent JComponent. The update includes a test for components that have been added previously using the standard add(Component) method. This will usually only be the case when added as part of a de-serialization.
        Specified by:
        paintPlot in interface GJPlotInterface
        Overrides:
        paintPlot in class GJAbstractPlot
        Parameters:
        g2 -

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.