public Point getLocation() { if (inEditMode) { tmpLoc.x = defLoc.x; tmpLoc.y = defLoc.y; } else { tmpLoc.x = curLoc.x; tmpLoc.y = curLoc.y; } return tmpLoc; }
public void reshape(int x, int y, int w, int h) { if (inEditMode) { defLoc.x = x; defLoc.y = y; defDim.width = w; defDim.height = h; } curLoc.x = x; curLoc.y = y; curDim.width = w; curDim.height = h; if (!inEditMode) { if ((h != nHeight) || (h < rHeight)) { adjustFont(w, h); } } super.reshape(x, y, w, h); }
public void setSizeRatio(double x, double y) { xRatio = x; yRatio = y; if (x > 1.0) xRatio = x - 1.0; if (y > 1.0) yRatio = y - 1.0; if (defDim.width <= 0) defDim = getPreferredSize(); curLoc.x = (int) ((double) defLoc.x * xRatio); curLoc.y = (int) ((double) defLoc.y * yRatio); curDim.width = (int) ((double) defDim.width * xRatio); curDim.height = (int) ((double) defDim.height * yRatio); if (!inEditMode) setBounds(curLoc.x, curLoc.y, curDim.width, curDim.height); }
public void setEditMode(boolean s) { if (s) { addMouseListener(ml); setOpaque(s); if (font != null) { setFont(font); fontH = font.getSize(); rHeight = fontH; } defDim = getPreferredSize(); curLoc.x = defLoc.x; curLoc.y = defLoc.y; curDim.width = defDim.width; curDim.height = defDim.height; xRatio = 1.0; yRatio = 1.0; } else { removeMouseListener(ml); if ((bg != null) || (isActive < 1)) setOpaque(true); else setOpaque(false); } inEditMode = s; }
public Point getDefLoc() { tmpLoc.x = defLoc.x; tmpLoc.y = defLoc.y; return tmpLoc; }
public void setDefLoc(int x, int y) { defLoc.x = x; defLoc.y = y; }
private void show( final IdeTooltip tooltip, @Nullable Runnable beforeShow, boolean animationEnabled) { boolean toCenterX; boolean toCenterY; boolean toCenter = tooltip.isToCenter(); boolean small = false; if (!toCenter && tooltip.isToCenterIfSmall()) { Dimension size = tooltip.getComponent().getSize(); toCenterX = size.width < 64; toCenterY = size.height < 64; toCenter = toCenterX || toCenterY; small = true; } else { toCenterX = true; toCenterY = true; } Point effectivePoint = tooltip.getPoint(); if (toCenter) { Rectangle bounds = tooltip.getComponent().getBounds(); effectivePoint.x = toCenterX ? bounds.width / 2 : effectivePoint.x; effectivePoint.y = toCenterY ? bounds.height / 2 : effectivePoint.y; } if (myCurrentComponent == tooltip.getComponent() && effectivePoint.equals(new Point(myX, myY))) { return; } Color bg = tooltip.getTextBackground() != null ? tooltip.getTextBackground() : getTextBackground(true); Color fg = tooltip.getTextForeground() != null ? tooltip.getTextForeground() : getTextForeground(true); Color border = tooltip.getBorderColor() != null ? tooltip.getBorderColor() : getBorderColor(true); BalloonBuilder builder = myPopupFactory .createBalloonBuilder(tooltip.getTipComponent()) .setPreferredPosition(tooltip.getPreferredPosition()) .setFillColor(bg) .setBorderColor(border) .setAnimationCycle( animationEnabled ? Registry.intValue("ide.tooltip.animationCycle") : 0) .setShowCallout(true) .setCalloutShift( small && tooltip.getCalloutShift() == 0 ? 2 : tooltip.getCalloutShift()) .setPositionChangeXShift(tooltip.getPositionChangeX()) .setPositionChangeYShift(tooltip.getPositionChangeY()) .setHideOnKeyOutside(!tooltip.isExplicitClose()) .setHideOnAction(!tooltip.isExplicitClose()) .setLayer(tooltip.getLayer()); tooltip.getTipComponent().setForeground(fg); tooltip.getTipComponent().setBorder(new EmptyBorder(1, 3, 2, 3)); tooltip .getTipComponent() .setFont(tooltip.getFont() != null ? tooltip.getFont() : getTextFont(true)); if (beforeShow != null) { beforeShow.run(); } myCurrentTipUi = (BalloonImpl) builder.createBalloon(); tooltip.setUi(myCurrentTipUi); myCurrentComponent = tooltip.getComponent(); myX = effectivePoint.x; myY = effectivePoint.y; myCurrentTipIsCentered = toCenter; myCurrentTooltip = tooltip; myShowRequest = null; myQueuedComponent = null; myQueuedTooltip = null; myCurrentTipUi.show( new RelativePoint(tooltip.getComponent(), effectivePoint), tooltip.getPreferredPosition()); myAlarm.addRequest( new Runnable() { @Override public void run() { if (myCurrentTooltip == tooltip && tooltip.canBeDismissedOnTimeout()) { hideCurrent(null, null, null); } } }, tooltip.getDismissDelay()); }