/** * Evaluate this bounds. The bounds member is updated. * * @param size Size of the Window to draw in. * @param flags Text Alignment flags. * @param posFlags Subzones Side bits. * @param transfo A transformation to locate this relatively to a center. * @param supCtr Center of the parent satellite (Place center). * @param center Center of this before the transformation. */ protected void setTextBnds( Dimension size, int flags, int posFlags, Transfo transfo, Point supCtr, Point center) { boolean isFloat = Base.isEnabled(flags, FLOAT_BIT); int dx = 0, dy = 0, x = center.x, y = center.y, w = m_bounds.width, h = m_bounds.height, w2 = w >> 1, h2 = h >> 1; if (supCtr != null) { dx = x - supCtr.x; dy = y - supCtr.y; } if (Base.isEnabled(flags, CORNER_BIT) && supCtr != null) { if ((posFlags & ActiveZone.SIDE_BIT) != 0) { x += (posFlags & ActiveZone.LEFT_BIT) != 0 ? w2 : -w2; } else { if (dx != 0) { x += dx > 0 ? w2 : -w2; } } if (dy != 0) { y += dy > 0 ? h2 : -h2; } } else if (isFloat) { x += w2; y += h2 + 32; // cursor height } if (transfo != null) { Point dp = transfo.getCart(); x += dp.x; y += dp.y; } x -= w2; y -= h2; if (isFloat) // avoid boundaries! { if (x < 0) x = 4; else if (x + w - 1 > size.width) x = size.width - 4 - w - 1; if (y < 0) y = 4; else if (y + h > size.height) y = size.height - 4 - h; } m_bounds.x = x; m_bounds.y = y; }
public void transform(Transfo transfo) { Transfo temp = this.peek(); this.pop(); temp.transform(transfo); stack.push(temp); }