/** * Checks what kind of button got hit at position (<code>x</code>, <code>y</code>). * * @param pX x-coordinate * @param pY y-coordinate * @return {@link #ASCENDING} or {@link #NONE} or {@link #DESCENDING}, depending on button that got hit */ public int hitButton(final int pX, final int pY) { Component component = mPanelButtons.findComponentAt(pX - mPanelButtons.getX(), pY - mPanelButtons.getY()); if (component != null && component.equals(mButtonSortAscending)) return ASCENDING; if (component != null && component.equals(mButtonSortDescending)) return DESCENDING; return NONE; }
public void paintComponent(Graphics g) { super.paintComponent(g); int x = bar.getX(); int y = bar.getY(); int h = bar.getHeight(); int w = bar.getWidth(); if (readSoFar <= 0 || total <= 0) { // make barber pole } else { double progress = (double)readSoFar / (double)total; int divide = (int)(w * progress); g.setColor(Color.white); g.fillRect(x, y, w, h); g.setColor(Color.blue); g.fillRect(x+1, y+1, divide-1, h-1); } } };
@Override public Dimension getPreferredSize() { if (isPreferredSizeSet()) { return super.getPreferredSize(); } Dimension dim = this.innerPanel.getPreferredSize(); if (this.titleIcon != null) { int iconHeight = this.titleIcon.getPreferredSize().height; Insets insets = this.innerPanel.getInsets(); int yBase = getTitleBar().getIconBase().getY(); int yBaseToTop = yBase + insets.top; dim.height += Math.max(0, iconHeight - yBaseToTop); } return dim; }
Utils.invokeLater(new Runnable() { @Override public void run() { final JViewport view = scroll.getViewport(); final Point current = view.getViewPosition(); final Dimension extent = view.getExtentSize(); final int panel_y = dp.getY(); if ((panel_y + DisplayablePanel.HEIGHT - current.y) <= extent.height && panel_y >= current.y) { // it's completely visible already return; } else { // scroll just enough // if it's above, show at the top if (panel_y - current.y < 0) { view.setViewPosition(new Point(0, panel_y)); } // if it's below (even if partially), show at the bottom else if (panel_y + 50 > current.y + extent.height) { view.setViewPosition(new Point(0, panel_y - extent.height + 50)); //Utils.log("Display.scrollToShow: panel_y: " + panel_y + " current.y: " + current.y + " extent.height: " + extent.height); } } }}); }
Random colorGenerator = new Random(); int curx = drawPanel.getX(); int cury = drawPanel.getY();
@Override protected final void paintBorder(Graphics g) { Border border = getBorder(); if (border != null) { int y = getInnerTitlePanel().getY() - getInsets().top - titleMargin; border.paintBorder(this, g, 0, y, getWidth(), getHeight() - y); } }
int y = getInnerTitlePanel().getY() - titleMargin; int height = getInnerTitlePanel().getHeight() + (2 * titleMargin);
/** * Selects the particular canvas at the specified index. * THe canvas is placed onto the it's glass pane and the placed onto * the canvasPane. A timer is used to roll out the canvasPane. * @param index */ public void selectCanvas(int index) { if ((!timer.timer.isRunning()) || (this.selectedCanvasIndex != index)) { if (index >= 0 && index < drawers.size()) { this.selectedCanvasIndex = index; GlassCard card = drawers.get(index); canvasPane.removeAll(); canvasPane.add(card.getScroll()); canvasPane.setBackground(card.getBackgorundColor()); timer.expand(); canvasPane.setBounds(buttonPane.getWidth(), buttonPane.getY(), 0, 0); this.requestFocus(); } } } /**
/** Creates the ui. */ @Override public void createUI() { if (!start.areFieldsConfigured()) { FieldPanel fieldPanel = createFieldPanel(getXPos(), Y_OFFSET, ""); createUIPanel( fieldPanel, start, 0, Localisation.getString(FieldConfigBase.class, "FieldConfigTimePeriod.from")); createUIPanel( fieldPanel, end, 1, Localisation.getString(FieldConfigBase.class, "FieldConfigTimePeriod.to")); Dimension preferredSize = new Dimension( (int) fieldPanel.getPreferredSize().getWidth(), end.panel.getY() + end.panel.getHeight()); fieldPanel.setPreferredSize(preferredSize); if (!isValueOnly()) { setAttributeSelectionPanel( fieldPanel.internalCreateAttrButton(Double.class, this, isRasterSymbol())); } } }