/** * @see edu.berkeley.guir.prefuse.action.Action#run(edu.berkeley.guir.prefuse.ItemRegistry, * double) */ public void run(double frac) { AggregateTable aggr = (AggregateTable) m_vis.getGroup(m_group); // do we have any to process? int num = aggr.getTupleCount(); if (num == 0) return; // update buffers int maxsz = 0; for (Iterator aggrs = aggr.tuples(); aggrs.hasNext(); ) maxsz = Math.max(maxsz, 4 * 2 * ((AggregateItem) aggrs.next()).getAggregateSize()); if (m_pts == null || maxsz > m_pts.length) { m_pts = new double[maxsz]; } // compute and assign convex hull for each aggregate Iterator aggrs = m_vis.visibleItems(m_group); while (aggrs.hasNext()) { AggregateItem aitem = (AggregateItem) aggrs.next(); int idx = 0; if (aitem.getAggregateSize() == 0) continue; VisualItem item = null; Iterator iter = aitem.items(); while (iter.hasNext()) { item = (VisualItem) iter.next(); if (item.isVisible()) { addPoint(m_pts, idx, item, m_margin); idx += 2 * 4; } } // if no aggregates are visible, do nothing if (idx == 0) continue; // compute convex hull double[] nhull = GraphicsLib.convexHull(m_pts, idx); // prepare viz attribute array float[] fhull = (float[]) aitem.get(VisualItem.POLYGON); if (fhull == null || fhull.length < nhull.length) fhull = new float[nhull.length]; else if (fhull.length > nhull.length) fhull[nhull.length] = Float.NaN; // copy hull values for (int j = 0; j < nhull.length; j++) fhull[j] = (float) nhull[j]; aitem.set(VisualItem.POLYGON, fhull); aitem.setValidated(false); // force invalidation } }