/** * ------------------------------------------------------ Render this container (i.e. the * background shape then all of it's parts). * * @param renderer the renderer to use for drawing * @overrides MiContainer#render ------------------------------------------------------ */ protected void render(MiRenderer renderer) { // ------------------------------------------------------- // Get the outer bounds of this container, subtract margins // from it, then assign these bounds to the background shape. // ------------------------------------------------------- MiBounds tmpBounds1 = MiBounds.newBounds(); MiBounds tmpBounds2 = MiBounds.newBounds(); getBounds(tmpBounds1); tmpBounds1.subtractMargins(getMargins(tmpMargins)); if (hasFixedWidthOrHeight) { shape.setFixedHeight(false); shape.setFixedWidth(false); } if (shape instanceof MiMultiPointShape) shape.setBounds(tmpBounds1); else shape.replaceBounds(tmpBounds1); // ------------------------------------------------------- // Assign this container's attributes to the background shape // and then draw the background shape. // ------------------------------------------------------- shape.replaceAttributes(getAttributes()); if (shape instanceof MiMultiPointShape) shape.refreshBounds(); else shape.replaceDrawBounds(getDrawBounds(tmpBounds1)); shape.draw(renderer); // ------------------------------------------------------- // Get the clip bounds from the renderer and then intersect // these clip bounds with the inner bounds of this container. // If there is such an intersection... // But use the _drawBounds_ because shadows (and ?) extend // outside the innerBounds. // ------------------------------------------------------- if (!okToDrawOutsideInnerBounds) { MiBounds clip = renderer.getClipBounds(tmpBounds1); if (getInnerBounds(tmpBounds2).intersectionWith(clip)) { // ------------------------------------------------------- // ... set the clip bounds of the renderer to this // intersection bounds, draw this containers contents // (in super.render()), then restore the clip bounds of // the renderer. // ------------------------------------------------------- renderer.setClipBounds(tmpBounds2); super.render(renderer); renderer.setClipBounds(clip); } } else { super.render(renderer); } MiBounds.freeBounds(tmpBounds1); MiBounds.freeBounds(tmpBounds2); }
/** * ------------------------------------------------------ Gets whether the given area intersects * the bounds of this MiPart. * * @param area the area * @return true if the given area overlaps the bounds of this MiPart. * @overrides MiPart#pick ------------------------------------------------------ */ public boolean pick(MiBounds area) { MiBounds tmpBounds = MiBounds.newBounds(); getBounds(tmpBounds); if (!tmpBounds.intersects(area)) { MiBounds.freeBounds(tmpBounds); return (false); } if (shape instanceof MiRectangle) { MiBounds.freeBounds(tmpBounds); return (true); } tmpBounds.subtractMargins(getMargins(tmpMargins)); shape.setBounds(tmpBounds); MiBounds.freeBounds(tmpBounds); return (shape.pick(area)); }
protected void layoutParts(int h_sizing, int v_sizing, int h_justification, int v_justification) { if (graphics != null) graphics.getPreferredSize(tmpSize); else if (strValue != null) attributes.getFont().getSize(strValue, tmpSize); else tmpSize.zeroOut(); MiBounds cellBounds = MiBounds.newBounds(); cellBounds.setSize(tmpSize); MiBounds theInnerBounds = tmpBounds; theInnerBounds.copy(innerBounds); if (margins != null) theInnerBounds.subtractMargins(margins); cellBounds.setCenterX(theInnerBounds.getCenterX()); cellBounds.setCenterY(theInnerBounds.getCenterY()); switch (h_sizing) { case Mi_EXPAND_TO_FILL: cellBounds.setWidth(theInnerBounds.getWidth()); break; case Mi_SAME_SIZE: cellBounds.setWidth(theInnerBounds.getWidth()); break; case Mi_NONE: default: break; } switch (v_sizing) { case Mi_EXPAND_TO_FILL: cellBounds.setHeight(theInnerBounds.getHeight()); break; case Mi_SAME_SIZE: cellBounds.setHeight(theInnerBounds.getHeight()); break; case Mi_NONE: default: break; } switch (h_justification) { case Mi_JUSTIFIED: case Mi_CENTER_JUSTIFIED: case Mi_NONE: cellBounds.setCenterX(theInnerBounds.getCenterX()); break; case Mi_LEFT_JUSTIFIED: cellBounds.translateXminTo(theInnerBounds.getXmin()); break; case Mi_RIGHT_JUSTIFIED: cellBounds.translateXmaxTo(theInnerBounds.getXmax()); break; } switch (v_justification) { case Mi_JUSTIFIED: case Mi_CENTER_JUSTIFIED: case Mi_NONE: cellBounds.setCenterY(theInnerBounds.getCenterY()); break; case Mi_BOTTOM_JUSTIFIED: cellBounds.translateYminTo(theInnerBounds.getYmin()); break; case Mi_TOP_JUSTIFIED: cellBounds.translateYmaxTo(theInnerBounds.getYmax()); break; } if (graphics != null) { graphics.setBounds(cellBounds); if (!graphics.hasValidLayout()) { graphics.validateLayout(); } } else { innerBounds.copy(cellBounds); } MiBounds.freeBounds(cellBounds); }