use of java.awt.Rectangle in project gephi by gephi.
the class SplineDisplay method resetSelection.
private void resetSelection() {
Point2D oldSelected = selected;
selected = null;
if (oldSelected != null) {
Rectangle bounds = getDraggableArea(oldSelected).getBounds();
repaint(bounds.x, bounds.y, bounds.width, bounds.height);
}
}
use of java.awt.Rectangle in project binnavi by google.
the class JHexView method drawMouseOverHighlighting.
/**
* Draws highlighting of bytes when the mouse hovers over them.
*
* @param g The graphics context where the highlighting is drawn.
*/
private void drawMouseOverHighlighting(final Graphics g) {
g.setColor(m_colorHighlight);
m_lastHighlightedNibble = getNibbleAtCoordinate(m_lastMouseX, m_lastMouseY);
if (m_lastHighlightedNibble == -1) {
return;
}
// Find out in which view the mouse currently resides.
final Views lastHighlightedView = m_lastMouseX >= getAsciiViewLeft() ? Views.ASCII_VIEW : Views.HEX_VIEW;
if (lastHighlightedView == Views.HEX_VIEW) {
// If the mouse is in the hex view just one nibble must be highlighted.
final Rectangle r = getNibbleBoundsHex(m_lastHighlightedNibble);
g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
} else if (lastHighlightedView == Views.ASCII_VIEW) {
// If the mouse is in the ASCII view it is necessary
// to highlight two nibbles.
// Don't change.
final int first = (2 * m_lastHighlightedNibble) / 2;
Rectangle r = getNibbleBoundsHex(first);
g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
r = getNibbleBoundsHex(first + 1);
g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
}
// Highlight the byte in the ASCII panel too.
final Rectangle r = getByteBoundsAscii(m_lastHighlightedNibble);
g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
}
use of java.awt.Rectangle in project processing by processing.
the class EditorState method defaultLocation.
/**
* Figure out the next location by sizing up the last editor in the list.
* If no editors are opened, it'll just open on the main screen.
* @param editors List of editors currently opened
*/
void defaultLocation(List<Editor> editors) {
int defaultWidth = Toolkit.zoom(Preferences.getInteger("editor.window.width.default"));
int defaultHeight = Toolkit.zoom(Preferences.getInteger("editor.window.height.default"));
defaultWidth = Math.min(defaultWidth, deviceBounds.width);
defaultHeight = Math.min(defaultHeight, deviceBounds.height);
if (editors.size() == 0) {
// If no current active editor, use default placement.
// Center the window on ths screen, taking into account that the
// upper-left corner of the device may have a non (0, 0) origin.
int editorX = deviceBounds.x + (deviceBounds.width - defaultWidth) / 2;
int editorY = deviceBounds.y + (deviceBounds.height - defaultHeight) / 2;
editorBounds = new Rectangle(editorX, editorY, defaultWidth, defaultHeight);
dividerLocation = 0;
} else {
// dimensions and divider location, but offset slightly.
synchronized (editors) {
Editor lastOpened = editors.get(editors.size() - 1);
isMaximized = (lastOpened.getExtendedState() == Frame.MAXIMIZED_BOTH);
editorBounds = lastOpened.getBounds();
editorBounds.x += WINDOW_OFFSET;
editorBounds.y += WINDOW_OFFSET;
dividerLocation = lastOpened.getDividerLocation();
if (!deviceBounds.contains(editorBounds)) {
// Warp the next window to a randomish location on screen.
editorBounds.x = deviceBounds.x + (int) (Math.random() * (deviceBounds.width - defaultWidth));
editorBounds.y = deviceBounds.y + (int) (Math.random() * (deviceBounds.height - defaultHeight));
}
if (isMaximized) {
editorBounds.width = defaultWidth;
editorBounds.height = defaultHeight;
}
}
}
}
use of java.awt.Rectangle in project processing by processing.
the class CompositionTextManager method getCaretRectangle.
private Rectangle getCaretRectangle(int x, int y) {
TextAreaPainter painter = textArea.getPainter();
Point origin = painter.getLocationOnScreen();
int height = painter.getFontMetrics().getHeight();
return new Rectangle(origin.x + x, origin.y + y, 0, height);
}
use of java.awt.Rectangle in project processing by processing.
the class CompositionTextPainter method draw.
/**
* Draw text via input method with composed text information.
* This method can draw texts with some underlines to illustrate converting characters.
*
* This method is workaround for TextAreaPainter.
* Because, TextAreaPainter can't treat AttributedCharacterIterator directly.
* AttributedCharacterIterator has very important information when composing text.
* It has a map where are converted characters and committed characters.
* Ideally, changing TextAreaPainter method can treat AttributedCharacterIterator is better. But it's very tough!!
* So I choose to write some code as a workaround.
*
* This draw method is proceeded with the following steps.
* 1. Original TextAreaPainter draws characters.
* 2. CompositionTextPainter.draw method paints composed text. It was actually drawn by TextLayout.
*
* @param gfx set TextAreaPainter's Graphics object.
* @param fillBackGroundColor set textarea's background.
*/
// public void draw(Graphics gfx, Color fillBackGroundColor) {
// assert(composedTextLayout != null);
// Point composedLoc = getCaretLocation();
// //refillComposedArea(fillBackGroundColor, composedLoc.x, composedLoc.y);
// composedTextLayout.draw((Graphics2D) gfx, composedLoc.x, composedLoc.y);
// }
public void draw(Graphics gfx, Color fillBackGroundColor) {
//assert(composedTextLayout != null);
if (composedTextLayout != null) {
Point composedLoc = getCaretLocation();
//refillComposedArea(fillBackGroundColor, composedLoc.x, composedLoc.y);
composedTextLayout.draw((Graphics2D) gfx, composedLoc.x, composedLoc.y);
// draw caret.
if (this.caret != null) {
int caretLocation = Math.round(composedTextLayout.getCaretInfo(caret)[0]);
Rectangle rect = new Rectangle(composedLoc.x + caretLocation, composedLoc.y - (int) composedTextLayout.getAscent(), 1, (int) composedTextLayout.getAscent() + (int) composedTextLayout.getDescent());
// save
Color c = gfx.getColor();
if (caretColorFlag) {
caretColorFlag = false;
gfx.setColor(Color.WHITE);
} else {
caretColorFlag = true;
gfx.setColor(Color.BLACK);
}
gfx.fillRect(rect.x, rect.y, rect.width, rect.height);
// restore
gfx.setColor(c);
}
}
}
Aggregations