/** * Renders the shape that is currently being sized by the user as they drag the mouse across the * canvas. We render this separately because we have not yet put it in the shapes list for the * pose. * * @param g2 The graphics context for this canvas. * @param poseArea The area in the middle of the canvas where the pose will be rendered. */ private void renderShapeInProgress(Graphics2D g2, Rectangle2D.Double poseArea) { AnimatedSpriteEditor singleton = AnimatedSpriteEditor.getEditor(); PoseurStateManager poseurStateManager = singleton.getStateManager().getPoseurStateManager(); PoseurShape shapeInProgress = poseurStateManager.getShapeInProgress(); // ONLY DO THIS ON THE RIGHT SIDE if (state.isZoomable() && (shapeInProgress != null)) { float zoomLevel = state.getZoomLevel(); shapeInProgress.render(g2, (int) poseArea.getX(), (int) poseArea.getY(), zoomLevel, true); } }
/** * Renders all the shapes in the corresponding canvas state object for this canvas. * * @param g2 The graphics context of this panel. */ private void renderShapes(Graphics2D g2, Rectangle2D.Double poseArea) { // LET'S GET THE POSE AREA AND THE POSE PoseurPose pose = state.getPose(); float zoomLevel = state.getZoomLevel(); // RENDER THE ENTIRE POSE Iterator<PoseurShape> shapesIt = pose.getShapesIterator(); AnimatedSpriteEditor singleton = AnimatedSpriteEditor.getEditor(); PoseurStateManager poseurStateManager = singleton.getStateManager().getPoseurStateManager(); while (shapesIt.hasNext()) { PoseurShape shape = shapesIt.next(); boolean isSelected = poseurStateManager.isSelectedShape(shape); // NOTE THAT WE NEVER DEPICT SELECTED SHAPES DIFFERENTLY // IN THE TRUE CANVAS, ONLY THE ZOOMABLE CANVAS if (!state.isZoomable()) { isSelected = false; } shape.render(g2, (int) poseArea.getX(), (int) poseArea.getY(), zoomLevel, isSelected); } }