/** * Gets the mark for the specified panel. * * @param trackerPanel the tracker panel * @return the mark */ protected Mark getMark(TrackerPanel trackerPanel) { Mark mark = marks.get(trackerPanel); TPoint selection = null; if (mark == null) { selection = trackerPanel.getSelectedPoint(); Point p = null; valid = true; // assume true for (int n = 0; n < points.length; n++) { if (!valid) continue; // determine if point is valid (ie not NaN) valid = valid && !Double.isNaN(points[n].getX()) && !Double.isNaN(points[n].getY()); screenPoints[n] = points[n].getScreenPosition(trackerPanel); if (valid && selection == points[n]) p = screenPoints[n]; } mark = footprint.getMark(screenPoints); if (p != null) { // point is selected, so draw selection shape transform.setToTranslation(p.x, p.y); int scale = FontSizer.getIntegerFactor(); if (scale > 1) { transform.scale(scale, scale); } final Color color = footprint.getColor(); final Mark stepMark = mark; final Shape selectedShape = transform.createTransformedShape(selectionShape); mark = new Mark() { public void draw(Graphics2D g, boolean highlighted) { stepMark.draw(g, false); Paint gpaint = g.getPaint(); g.setPaint(color); g.fill(selectedShape); g.setPaint(gpaint); } public Rectangle getBounds(boolean highlighted) { Rectangle bounds = selectedShape.getBounds(); bounds.add(stepMark.getBounds(false)); return bounds; } }; } final Mark theMark = mark; mark = new Mark() { public void draw(Graphics2D g, boolean highlighted) { if (!valid) return; theMark.draw(g, false); } public Rectangle getBounds(boolean highlighted) { return theMark.getBounds(highlighted); } }; marks.put(trackerPanel, mark); } return mark; }
/** * Overrides Step getMark method. * * @param trackerPanel the tracker panel * @return the mark */ protected Mark getMark(TrackerPanel trackerPanel) { Mark mark = marks.get(trackerPanel); TPoint selection = null; if (mark == null) { selection = trackerPanel.getSelectedPoint(); Point p = null; // draws this step as "selected" shape if not null valid = true; // true if step is not NaN for (int n = 0; n < points.length; n++) { if (!valid) continue; // determine if point is valid (ie not NaN) valid = valid && !Double.isNaN(points[n].getX()) && !Double.isNaN(points[n].getY()); screenPoints[n] = points[n].getScreenPosition(trackerPanel); // step is "selected" if trackerPanel selectedPoint is position or selectedSteps contains // this step if (valid && (selection == points[n] || trackerPanel.selectedSteps.contains(this))) { p = screenPoints[n]; } } if (p == null) { if (footprint instanceof PositionVectorFootprint) { twoPoints[0] = screenPoints[0]; twoPoints[1] = trackerPanel.getSnapPoint().getScreenPosition(trackerPanel); mark = footprint.getMark(twoPoints); } else mark = footprint.getMark(screenPoints); } else { transform.setToTranslation(p.x, p.y); int scale = FontSizer.getIntegerFactor(); if (scale > 1) { transform.scale(scale, scale); } final Color color = footprint.getColor(); final Shape selectedShape = transform.createTransformedShape(selectionShape); mark = new Mark() { public void draw(Graphics2D g, boolean highlighted) { g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Paint gpaint = g.getPaint(); g.setPaint(color); g.fill(selectedShape); g.setPaint(gpaint); } public Rectangle getBounds(boolean highlighted) { return selectedShape.getBounds(); } }; } final Mark theMark = mark; mark = new Mark() { public void draw(Graphics2D g, boolean highlighted) { if (!valid) { return; } theMark.draw(g, highlighted); } public Rectangle getBounds(boolean highlighted) { return theMark.getBounds(highlighted); } }; marks.put(trackerPanel, mark); // get new text layout String s = ""; // $NON-NLS-1$ VideoClip clip = trackerPanel.getPlayer().getVideoClip(); if (clip.getStepCount() != 1) { s += clip.frameToStep(getFrameNumber()); } if (s.length() == 0) s = " "; // $NON-NLS-1$ TextLayout layout = new TextLayout(s, textLayoutFont, frc); textLayouts.put(trackerPanel, layout); // get layout position (bottom left corner of text) p = getLayoutPosition(trackerPanel); Rectangle bounds = layoutBounds.get(trackerPanel); if (bounds == null) { bounds = new Rectangle(); layoutBounds.put(trackerPanel, bounds); } Rectangle2D rect = layout.getBounds(); // set bounds (top left corner and size) bounds.setRect(p.x, p.y - rect.getHeight(), rect.getWidth(), rect.getHeight()); } return mark; }