예제 #1
0
 public NodeColorAction(String group) {
   super(group, VisualItem.FILLCOLOR, ColorLib.rgba(202, 225, 255, 250));
   add("_hover", ColorLib.gray(220, 230));
   add("ingroup('_search_')", ColorLib.rgb(255, 190, 190));
   add("ingroup('_focus_')", ColorLib.rgb(205, 197, 191));
   add(isprocessfilter, ColorLib.rgba(255, 193, 193, 255));
 }
예제 #2
0
 public NodeColorAction(
     DocuBurstActionList docuBurstActionList, String group, boolean trackSenseIndex) {
   super(group, VisualItem.FILLCOLOR, ColorLib.rgba(100, 100, 100, 0));
   this.docuBurstActionList = docuBurstActionList;
   add("type = 1", new WordCountColorAction(group, VisualItem.FILLCOLOR));
 }
 public int getColor(VisualItem item) {
   if (m_vis.isInGroup(item, Visualization.SEARCH_ITEMS)) return ColorLib.rgb(255, 190, 190);
   else if (m_vis.isInGroup(item, Visualization.FOCUS_ITEMS)) return ColorLib.rgb(198, 229, 229);
   else if (item.getDOI() > -1) return ColorLib.rgb(164, 193, 193);
   else return ColorLib.rgba(255, 255, 255, 0);
 }
예제 #4
0
  public MPtrack(Table t) {
    super(new BorderLayout());

    // --------------------------------------------------------------------
    // STEP 1: setup the visualized data

    final Visualization vis = new Visualization();
    m_vis = vis;

    final String group = "by_state";

    VisualTable vt = vis.addTable(group, t);

    vis.setRendererFactory(
        new RendererFactory() {
          AbstractShapeRenderer sr = new ShapeRenderer(30);
          Renderer arY = new AxisRenderer(Constants.RIGHT, Constants.TOP);
          Renderer arX = new AxisRenderer(Constants.CENTER, Constants.FAR_BOTTOM);

          public Renderer getRenderer(VisualItem item) {
            return item.isInGroup("ylab") ? arY : item.isInGroup("xlab") ? arX : sr;
          }
        });

    // --------------------------------------------------------------------

    // set up the actions
    AxisLayout xaxis = new AxisLayout(group, "States", Constants.X_AXIS, VisiblePredicate.TRUE);
    AxisLayout yaxis = new AxisLayout(group, PARTY, Constants.Y_AXIS, VisiblePredicate.TRUE);
    // yaxis.setScale(Constants.LOG_SCALE);

    xaxis.setLayoutBounds(m_dataB);
    yaxis.setLayoutBounds(m_dataB);

    AxisLabelLayout ylabels = new AxisLabelLayout("ylab", yaxis, m_ylabB, 5);

    AxisLabelLayout xlabels = new AxisLabelLayout("xlab", xaxis, m_xlabB, 5);
    vis.putAction("xlabels", xlabels);

    int[] palette = new int[] {ColorLib.rgb(150, 150, 255)};

    int[] palette2 = new int[200];

    for (int i = 0; i < 200; i++) {
      palette2[i] = ColorLib.rgba(255, 0, 0, 2 * i);
    }

    /*
    DataColorAction color = new DataColorAction(group, "Party",
            Constants.ORDINAL, VisualItem.STROKECOLOR, palette);
            */

    DataColorAction color2 =
        new DataColorAction(group, "Attendance", Constants.ORDINAL, VisualItem.FILLCOLOR, palette2);

    ActionList draw = new ActionList();
    draw.add(color2);
    draw.add(xaxis);
    draw.add(yaxis);
    draw.add(ylabels);
    draw.add(new RepaintAction());
    vis.putAction("draw", draw);

    ActionList update = new ActionList();
    update.add(xaxis);
    update.add(yaxis);
    update.add(ylabels);
    update.add(new RepaintAction());
    vis.putAction("update", update);

    UpdateListener lstnr =
        new UpdateListener() {
          public void update(Object src) {
            vis.run("update");
          }
        };

    // --------------------------------------------------------------------
    // STEP 4: set up a display and ui components to show the visualization

    m_display = new Display(vis);

    m_display.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    m_display.setSize(700, 450);
    m_display.setHighQuality(true);
    m_display.addComponentListener(
        new ComponentAdapter() {
          public void componentResized(ComponentEvent e) {
            displayLayout();
          }
        });
    displayLayout();

    m_details = new JFastLabel(m_title);
    m_details.setPreferredSize(new Dimension(75, 20));
    m_details.setVerticalAlignment(SwingConstants.BOTTOM);

    ToolTipControl ttc = new ToolTipControl("label");
    Control hoverc =
        new ControlAdapter() {
          public void itemEntered(VisualItem item, MouseEvent evt) {
            if (item.isInGroup(group)) {
              item.setFillColor(item.getStrokeColor());
              item.setStrokeColor(ColorLib.rgb(0, 0, 0));
              item.getVisualization().repaint();
            }
          }

          public void itemExited(VisualItem item, MouseEvent evt) {
            if (item.isInGroup(group)) {
              item.setFillColor(item.getEndFillColor());
              item.setStrokeColor(item.getEndStrokeColor());
              item.getVisualization().repaint();
            }
          }
        };
    m_display.addControlListener(ttc);
    m_display.addControlListener(hoverc);

    // --------------------------------------------------------------------
    // STEP 5: launching the visualization

    this.addComponentListener(lstnr);

    // details
    Box infoBox = new Box(BoxLayout.X_AXIS);
    infoBox.add(Box.createHorizontalStrut(5));
    infoBox.add(m_details);
    infoBox.add(Box.createHorizontalGlue());
    infoBox.add(Box.createHorizontalStrut(5));
    infoBox.add(Box.createHorizontalStrut(5));

    // create dynamic queries
    Box radioBox = new Box(BoxLayout.X_AXIS);
    radioBox.add(Box.createHorizontalStrut(5));
    radioBox.add(Box.createHorizontalGlue());
    radioBox.add(Box.createHorizontalStrut(5));
    radioBox.add(Box.createHorizontalStrut(16));

    vis.run("draw");
    vis.run("xlabels");

    add(infoBox, BorderLayout.NORTH);
    add(m_display, BorderLayout.CENTER);
    add(radioBox, BorderLayout.SOUTH);
    UILib.setColor(this, ColorLib.getColor(255, 255, 255), Color.GRAY);
    UILib.setFont(radioBox, FontLib.getFont("Tahoma", 15));
    m_details.setFont(FontLib.getFont("Tahoma", 18));
  }
예제 #5
0
 public BorderColorAction(String group) {
   super(group, VisualItem.STROKECOLOR, ColorLib.rgba(0, 0, 255, 255));
   add(isprocessfilter, ColorLib.rgba(176, 23, 31, 255));
 }
예제 #6
0
  public AggregateDemo() {
    // initialize display and data
    super(new Visualization());
    initDataGroups();

    // set up the renderers
    // draw the nodes as basic shapes
    Renderer nodeR = new ShapeRenderer(20);
    // draw aggregates as polygons with curved edges
    Renderer polyR = new PolygonRenderer(Constants.POLY_TYPE_CURVE);
    ((PolygonRenderer) polyR).setCurveSlack(0.15f);

    // modification to try drawing edges to aggregates
    Renderer edgeR =
        new EdgeRenderer() {
          @Override
          protected Shape getRawShape(VisualItem item) {
            EdgeItem edge = (EdgeItem) item;
            VisualItem item1 = edge.getSourceItem();
            VisualItem item2 = edge.getTargetItem();
            item2 = (AggregateItem) at.getAggregates(item2).next();

            int type = m_edgeType;

            getAlignedPoint(m_tmpPoints[0], item1.getBounds(), m_xAlign1, m_yAlign1);
            getAlignedPoint(m_tmpPoints[1], item2.getBounds(), m_xAlign2, m_yAlign2);
            m_curWidth = (float) (m_width * getLineWidth(item));

            // create the arrow head, if needed
            EdgeItem e = (EdgeItem) item;
            if (e.isDirected() && m_edgeArrow != Constants.EDGE_ARROW_NONE) {
              // get starting and ending edge endpoints
              boolean forward = (m_edgeArrow == Constants.EDGE_ARROW_FORWARD);
              Point2D start = null, end = null;
              start = m_tmpPoints[forward ? 0 : 1];
              end = m_tmpPoints[forward ? 1 : 0];

              // compute the intersection with the target bounding box
              VisualItem dest = forward ? e.getTargetItem() : e.getSourceItem();
              int i =
                  GraphicsLib.intersectLineRectangle(start, end, dest.getBounds(), m_isctPoints);
              if (i > 0) end = m_isctPoints[0];

              // create the arrow head shape
              AffineTransform at = getArrowTrans(start, end, m_curWidth);
              m_curArrow = at.createTransformedShape(m_arrowHead);

              // update the endpoints for the edge shape
              // need to bias this by arrow head size
              Point2D lineEnd = m_tmpPoints[forward ? 1 : 0];
              lineEnd.setLocation(0, -m_arrowHeight);
              at.transform(lineEnd, lineEnd);
            } else {
              m_curArrow = null;
            }

            // create the edge shape
            Shape shape = null;
            double n1x = m_tmpPoints[0].getX();
            double n1y = m_tmpPoints[0].getY();
            double n2x = m_tmpPoints[1].getX();
            double n2y = m_tmpPoints[1].getY();
            switch (type) {
              case Constants.EDGE_TYPE_LINE:
                m_line.setLine(n1x, n1y, n2x, n2y);
                shape = m_line;
                break;
              case Constants.EDGE_TYPE_CURVE:
                getCurveControlPoints(edge, m_ctrlPoints, n1x, n1y, n2x, n2y);
                m_cubic.setCurve(
                    n1x,
                    n1y,
                    m_ctrlPoints[0].getX(),
                    m_ctrlPoints[0].getY(),
                    m_ctrlPoints[1].getX(),
                    m_ctrlPoints[1].getY(),
                    n2x,
                    n2y);
                shape = m_cubic;
                break;
              default:
                throw new IllegalStateException("Unknown edge type");
            }

            // return the edge shape
            return shape;
          }
        };

    DefaultRendererFactory drf = new DefaultRendererFactory(nodeR, edgeR);
    drf.add("ingroup('aggregates')", polyR);
    m_vis.setRendererFactory(drf);

    // set up the visual operators
    // first set up all the color actions
    ColorAction nStroke = new ColorAction(NODES, VisualItem.STROKECOLOR);
    nStroke.setDefaultColor(ColorLib.gray(100));
    nStroke.add("_hover", ColorLib.gray(50));

    ColorAction nFill = new ColorAction(NODES, VisualItem.FILLCOLOR);
    nFill.setDefaultColor(ColorLib.gray(255));
    nFill.add("_hover", ColorLib.gray(200));

    ColorAction nEdges = new ColorAction(EDGES, VisualItem.STROKECOLOR);
    nEdges.setDefaultColor(ColorLib.gray(100));

    ColorAction aStroke = new ColorAction(AGGR, VisualItem.STROKECOLOR);
    aStroke.setDefaultColor(ColorLib.gray(200));
    aStroke.add("_hover", ColorLib.rgb(255, 100, 100));

    int[] palette =
        new int[] {
          ColorLib.rgba(255, 200, 200, 255),
          ColorLib.rgba(200, 255, 200, 255),
          ColorLib.rgba(200, 200, 255, 255)
        };
    ColorAction aFill =
        new DataColorAction(AGGR, "id", Constants.NOMINAL, VisualItem.FILLCOLOR, palette);

    // bundle the color actions
    ActionList colors = new ActionList();
    colors.add(nStroke);
    colors.add(nFill);
    colors.add(nEdges);
    colors.add(aStroke);
    colors.add(aFill);

    // now create the main layout routine
    ActionList layout = new ActionList(Activity.INFINITY);
    layout.add(colors);
    layout.add(new ForceDirectedLayout(GRAPH, true));
    layout.add(new AggregateLayout(AGGR));
    layout.add(new RepaintAction());
    m_vis.putAction("layout", layout);

    // set up the display
    setSize(500, 500);
    pan(250, 250);
    setHighQuality(true);
    addControlListener(new AggregateDragControl());
    addControlListener(new ZoomControl());
    addControlListener(new PanControl());

    // set things running
    m_vis.run("layout");
  }