/** * Repaint the given line range. * * @param line0 The starting line number to repaint. This must be a valid line number in the * model. * @param line1 The ending line number to repaint. This must be a valid line number in the model. * @param a The region allocated for the view to render into. * @param host The component hosting the view (used to call repaint). */ protected void damageLineRange(int line0, int line1, Shape a, Component host) { if (a != null) { Rectangle area0 = lineToRect(a, line0); Rectangle area1 = lineToRect(a, line1); if ((area0 != null) && (area1 != null)) { Rectangle dmg = area0.union(area1); // damage. host.repaint(dmg.x, dmg.y, dmg.width, dmg.height); } else host.repaint(); } }
/** * Move this LineSelection to the coordinate (x,y) in the parent's coordinate space. This calls * the repaint() method of the LineSelection's component, which is ultimately responsible for * calling the LineSelectio's draw() method. * * @param _x the x coordinate * @param _y the y coordinate */ public void move(int _x, int _y) { int oldx = x; int oldy = y; x = _x; y = _y; if (component != null) { // just need to repaint the necessary areas component.repaint(oldx, oldy, width + 1, height + 1); component.repaint(x, y, width + 1, height + 1); } } // end move
/** * Repaint the region of change covered by the given document event. Damages the line that begins * the range to cover the case when the insert/remove is only on one line. If lines are added or * removed, damages the whole view. The longest line is checked to see if it has changed. */ protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f) { Component host = getContainer(); updateMetrics(); Element elem = getElement(); DocumentEvent.ElementChange ec = changes.getChange(elem); Element[] added = (ec != null) ? ec.getChildrenAdded() : null; Element[] removed = (ec != null) ? ec.getChildrenRemoved() : null; if (((added != null) && (added.length > 0)) || ((removed != null) && (removed.length > 0))) { // lines were added or removed... if (added != null) { int addedAt = ec.getIndex(); // FIXME: Is this correct????? for (int i = 0; i < added.length; i++) possiblyUpdateLongLine(added[i], addedAt + i); } if (removed != null) { for (int i = 0; i < removed.length; i++) { if (removed[i] == longLine) { longLineWidth = -1; // Must do this!! calculateLongestLine(); break; } } } preferenceChanged(null, true, true); host.repaint(); } // This occurs when syntax highlighting only changes on lines // (i.e. beginning a multiline comment). else if (changes.getType() == DocumentEvent.EventType.CHANGE) { // System.err.println("Updating the damage due to a CHANGE event..."); int startLine = changes.getOffset(); int endLine = changes.getLength(); damageLineRange(startLine, endLine, a, host); } else { Element map = getElement(); int line = map.getElementIndex(changes.getOffset()); damageLineRange(line, line, a, host); if (changes.getType() == DocumentEvent.EventType.INSERT) { // check to see if the line is longer than current // longest line. Element e = map.getElement(line); if (e == longLine) { // We must recalculate longest line's width here // because it has gotten longer. longLineWidth = getLineWidth(line); preferenceChanged(null, true, false); } else { // If long line gets updated, update the status bars too. if (possiblyUpdateLongLine(e, line)) preferenceChanged(null, true, false); } } else if (changes.getType() == DocumentEvent.EventType.REMOVE) { if (map.getElement(line) == longLine) { // removed from longest line... recalc longLineWidth = -1; // Must do this! calculateLongestLine(); preferenceChanged(null, true, false); } } } }
public void focusLost(FocusEvent e) { // We will still paint focus even if lost temporarily focusLostTemporarily = e.isTemporary(); if (!focusLostTemporarily) { comp.repaint(); } }
/** refreshes the parents */ protected void refreshParents() { if (componentToRefresh != null) { componentToRefresh.repaint(); } }
private void repaint() { if (mPainter != null) { if (DEBUG.IMAGE) out("repaint in " + GUI.name(mPainter)); mPainter.repaint(); } // FYI, this will not repaint if the parent is a DefaultTreeCellRenderer, // and the parent of the parent (a JLabel), is null, so we can't get that. }
public StatusText clear() { myText = ""; myComponent.clear(); myClickListeners.clear(); myHasActiveClickListeners = false; if (myOwner != null && isStatusVisible()) myOwner.repaint(); return this; }
/** * Gives notification from the document that attributes were changed in a location that this * view is responsible for. * * @param fv the <code>FlowView</code> containing the changes * @param e the <code>DocumentEvent</code> describing the changes done to the Document * @param alloc Bounds of the View * @see View#changedUpdate */ public void changedUpdate(FlowView fv, DocumentEvent e, Rectangle alloc) { if (alloc != null) { Component host = fv.getContainer(); if (host != null) { host.repaint(alloc.x, alloc.y, alloc.width, alloc.height); } } else { fv.layoutChanged(View.X_AXIS); fv.layoutChanged(View.Y_AXIS); } }
private void updateSelectedObj() { // System.out.println("VtabbedToolPanel updateValue "); Component comp = getSelectedObj(); if (comp != null) { if (comp instanceof ExpListenerIF) ((ExpListenerIF) comp).updateValue(); if (comp instanceof EditListenerIF) { ((EditListenerIF) comp).setEditMode(inEditMode); comp.repaint(); } } }
/** * Display a file chooser dialog box. * * @param owner <code>Component</code> which 'owns' the dialog * @param mode Can be either <code>OPEN</code>, <code>SCRIPT</code> or <code>SAVE</code> * @return The path to selected file, null otherwise */ public static String chooseFile(Component owner, int mode) { JFileChooser chooser = getFileChooser(owner, mode); chooser.setMultiSelectionEnabled(false); if (chooser.showDialog(owner, null) == JFileChooser.APPROVE_OPTION) { /*Jext*/ AbstractEditorPanel.setProperty( "lastdir." + mode, chooser.getSelectedFile().getParent()); return chooser.getSelectedFile().getAbsolutePath(); } else owner.repaint(); return null; }
/** * ������ѡ���� * * @param cp ����Ҫ�ı�Ŀؼ� * @param style ���ܽ����±� * @return ���سɹ�������� */ public static boolean setUI(Component cp, int style) { try { switch (style) { case 0: UIManager.setLookAndFeel("com.sun.java.swing.plaf." + "windows.WindowsLookAndFeel"); break; case 1: UIManager.setLookAndFeel("javax.swing.plaf." + "metal.MetalLookAndFeel"); break; case 2: UIManager.setLookAndFeel("com.sun.java.swing.plaf." + "motif.MotifLookAndFeel"); break; case 3: UIManager.setLookAndFeel( "com.sun.java.swing.plaf." + "windows.WindowsClassicLookAndFeel"); break; case 4: UIManager.setLookAndFeel("com.incors.plaf." + "alloy.AlloyLookAndFeel"); break; case 5: UIManager.setLookAndFeel("soft.wes.feels." + "GlassThemeAlloyLookAndFeel"); break; case 6: UIManager.setLookAndFeel("soft.wes.feels." + "AcidThemeAlloyLookAndFeel"); break; case 7: UIManager.setLookAndFeel("soft.wes.feels." + "BedouinThemeAlloyLookAndFeel"); break; case 8: UIManager.setLookAndFeel("soft.wes.feels." + "DefaultThemeAlloyLookAndFeel"); break; case 9: UIManager.put("swing.boldMetal", Boolean.FALSE); // �����öԻ������ JDialog.setDefaultLookAndFeelDecorated(true); // ���������ô������ JFrame.setDefaultLookAndFeelDecorated(true); Toolkit.getDefaultToolkit().setDynamicLayout(true); System.setProperty("sun.awt.noerasebackground", "true"); UIManager.setLookAndFeel(new MetalLookAndFeel()); break; } } catch (Exception ex) { JOptionPane.showMessageDialog(null, "����ʧ��,��ԭ�����ʾ"); return false; } SwingUtilities.updateComponentTreeUI(cp); cp.repaint(); return true; }
private void paintFocusBorders(boolean clean) { if (myCurrent != null) { Graphics currentFocusGraphics = myCurrent.getGraphics(); if (currentFocusGraphics != null) { if (clean) { if (myCurrent.isDisplayable()) { myCurrent.repaint(); } } else { currentFocusGraphics.setColor(myTemporary ? JBColor.ORANGE : JBColor.GREEN); UIUtil.drawDottedRectangle( currentFocusGraphics, 1, 1, myCurrent.getSize().width - 2, myCurrent.getSize().height - 2); } } } if (myPrevious != null) { Graphics previousFocusGraphics = myPrevious.getGraphics(); if (previousFocusGraphics != null) { if (clean) { if (myPrevious.isDisplayable()) { myPrevious.repaint(); } } else { previousFocusGraphics.setColor(JBColor.RED); UIUtil.drawDottedRectangle( previousFocusGraphics, 1, 1, myPrevious.getSize().width - 2, myPrevious.getSize().height - 2); } } } }
@Override public void run() { try { while (running) { sleep(100); paintBorder(); } if (prev != null) { prev.repaint(); } } catch (InterruptedException e) { // } }
private void onClick() { try { DialogTabularParameter dlg = new DialogTabularParameter(cmpCaller, mbModal, mstrTitle, mvtDefinition, mvtValue); // DialogTableParameter dlg = new // DialogTableParameter(cmpCaller,mbModal,mstrTitle,mvtDefinition,mvtValue); WindowManager.centeredWindow(dlg); cmpCaller.repaint(); setValue(mvtValue); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } }
public StatusText appendText(String text, SimpleTextAttributes attrs, ActionListener listener) { if (myIsDefaultText) { clear(); myIsDefaultText = false; } myText += text; myComponent.append(text, attrs); myClickListeners.add(listener); if (listener != null) { myHasActiveClickListeners = true; } if (myOwner != null && isStatusVisible()) myOwner.repaint(); return this; }
private void paintBorder() { final int row = FocusTracesDialog.this.myRequestsTable.getSelectedRow(); if (row != -1) { final FocusRequestInfo info = FocusTracesDialog.this.myRequests.get(row); if (prev != null && prev != info.getComponent()) { prev.repaint(); } prev = info.getComponent(); if (prev != null && prev.isDisplayable()) { final Graphics g = prev.getGraphics(); g.setColor(Color.RED); final Dimension sz = prev.getSize(); UIUtil.drawDottedRectangle(g, 1, 1, sz.width - 2, sz.height - 2); } } }
private void handleDocumentEvent(DocumentEvent e, Shape a, ViewFactory f) { int n = calculateLineCount(); if (this.nlines != n) { this.nlines = n; WrappedSyntaxView.this.preferenceChanged(this, false, true); // have to repaint any views after the receiver. RSyntaxTextArea textArea = (RSyntaxTextArea) getContainer(); textArea.repaint(); // Must also revalidate container so gutter components, such // as line numbers, get updated for this line's new height Gutter gutter = RSyntaxUtilities.getGutter(textArea); if (gutter != null) { gutter.revalidate(); gutter.repaint(); } } else if (a != null) { Component c = getContainer(); Rectangle alloc = (Rectangle) a; c.repaint(alloc.x, alloc.y, alloc.width, alloc.height); } }
/** * Lays out the children. If the span along the flow axis has changed, layout is marked as invalid * which which will cause the superclass behavior to recalculate the layout along the box axis. * The FlowStrategy.layout method will be called to rebuild the flow rows as appropriate. If the * height of this view changes (determined by the perferred size along the box axis), a * preferenceChanged is called. Following all of that, the normal box layout of the superclass is * performed. * * @param width the width to lay out against >= 0. This is the width inside of the inset area. * @param height the height to lay out against >= 0 This is the height inside of the inset area. */ protected void layout(int width, int height) { final int faxis = getFlowAxis(); int newSpan; if (faxis == X_AXIS) { newSpan = (int) width; } else { newSpan = (int) height; } if (layoutSpan != newSpan) { layoutChanged(faxis); layoutChanged(getAxis()); layoutSpan = newSpan; } // repair the flow if necessary if (!isLayoutValid(faxis)) { final int heightAxis = getAxis(); int oldFlowHeight = (int) ((heightAxis == X_AXIS) ? getWidth() : getHeight()); strategy.layout(this); int newFlowHeight = (int) getPreferredSpan(heightAxis); if (oldFlowHeight != newFlowHeight) { View p = getParent(); if (p != null) { p.preferenceChanged(this, (heightAxis == X_AXIS), (heightAxis == Y_AXIS)); } // PENDING(shannonh) // Temporary fix for 4250847 // Can be removed when TraversalContext is added Component host = getContainer(); if (host != null) { // nb idk 12/12/2001 host should not be equal to null. We need to add assertion here host.repaint(); } } } super.layout(width, height); }
/** Cause a redisplay of the LineSelection (by calling the component's repaint() method). */ private void redraw() { if (component != null) { // need to just repaint the necessary area component.repaint(); } }
public void focusGained(FocusEvent e) { comp.repaint(); }
public void run() { /** * /////test part//// mPoint testp1 = new mPoint(1,1,3,0.5f); mPoint testp2 = new * mPoint(70,50,20,0.5f); // mMath.LinearInterpolation(testp1,testp2); // * System.out.println(testp1.x+" \n"+testp2.x); * * <p>canvas.drawLine(testp1,testp2); * * <p>// mPoint3 p[] = {new mPoint3(1,2,3),new mPoint3(2,1,3),new mPoint3(3,4,5)}; mPoint p[] = * {new mPoint(70,1,3,1),new mPoint(1,40,3,1),new mPoint(70,60,5,1)}; canvas.fillTriangle(p); */ /** * --the way to create objects in a world mOject obj = new mObject(...); mWorld w = new * mWorld(); w.add(obj); --draw it mCamera cam = new mCamera(...); cam.capture(w); //cam will * refresh the bufferedImage own.repaint(); //will refresh the window with bufferedImage */ mCube cube = new mCube(new mPoint3(0, 90, -80), 100, 100, 100); // mCube cube2 = new mCube(new mPoint3(-300,300,0),500,500,500); mCone cone = new mCone(new mPoint3(0, 50, 0), 80, 200); mObject obj = new mObject(); obj = createRandomSurface(obj, 0, 200, 60, 260); /*obj.shape = new mShape(); obj.pos=new mPoint3(50,0,0); mPoint3[] points={ obj.pos, new mPoint3(50,50,0), new mPoint3(100,0,0), new mPoint3(100,50,0) }; short[][] tripoints = { {0,0}, {3,2}, {1,3} }; short[][] linepoints = new short[2][0]; obj.center = new mVector3(0,0,0); obj.shape.set(points,linepoints,tripoints); obj.refer = new mReferenceTransformation(new mPoint3(obj.pos,obj.center), new mVector3(0,1,0), new mVector3(1,0,0));*/ mGrid grid = new mGrid(100); mWorld w = new mWorld(); w.add(cube); // w.add(cube2); w.add(grid); w.add(cone); w.add(obj); mCamera cam = new mCamera(canvas); cam.capture(w); own.repaint(speed); /* CoordinateTransformation.test(); mTriangle tri = new mTriangle(p); /* for(int i=0;i<20;i++){ cube.rotate((float)Math.PI/40,(float)Math.PI/40,(float)Math.PI/40); cube.move(new mVector3(0,5,0)); try{ this.sleep(90); }catch(InterruptedException e){ System.err.println(e.getMessage()); } canvas.clear(); cam.capture(w); own.repaint(); }//*/ for (int i = 0; i < 10; i++) { cube.rotate(0, (float) Math.PI / 20, (float) Math.PI / 20); // (float)Math.PI/20); cube.move(new mVector3(10, 0, 10)); try { this.sleep(speed); } catch (InterruptedException e) { System.err.println(e.getMessage()); } canvas.clear(); cam.capture(w); own.repaint(speed); // timeout = 60 } // */ for (int i = 0; i < 20; i++) { cube.rotate((float) Math.PI / 40, 0, (float) Math.PI / 40); // (float)Math.PI/20); cube.move(new mVector3(-10, -5, 0)); try { this.sleep(speed); } catch (InterruptedException e) { System.err.println(e.getMessage()); } canvas.clear(); cam.capture(w); own.repaint(speed); } // */ // int time = 0; while (true) { cam.rotate((float) Math.PI / 30, 0, 0); // time++; // float move = 30*(float)Math.sin((float)time/5); // cam.move(new mVector3(move,move,move)); try { this.sleep(speed); } catch (InterruptedException e) { System.err.println(e.getMessage()); } canvas.clear(); cam.capture(w); own.repaint(speed); } // */ }
protected void addImpl(Component child, Object constraints, int index) { synchronized (treeLock) { if (index < -1 || index > nChildren) { throw new IllegalArgumentException("bad index: " + index); } // This test isn't done because we actually need this functionality // for the native windowing system // else if (child instanceof Window) { // throw new IllegalArgumentException("component is Window"); // } else if (child instanceof Container && this.parent == child) { throw new IllegalArgumentException("child is a bad container"); } if (child.parent != null) { child.parent.remove(child); } if (children == null) { children = new Component[3]; } else if (nChildren == children.length) { Component[] old = children; children = new Component[nChildren * 2]; System.arraycopy(old, 0, children, 0, nChildren); } if (index < 0 || nChildren == 0 || index == nChildren) { // append children[nChildren] = child; } else if (index < nChildren) { // insert at index System.arraycopy(children, index, children, index + 1, nChildren - index); children[index] = child; } nChildren++; child.parent = this; if ((flags & IS_VALID) != 0) invalidate(); // if we are already addNotified (this is a subsequent add), // we immediately have to addNotify the child, too if ((flags & IS_ADD_NOTIFIED) != 0) { child.addNotify(); // This isn't required in case we are subsequently validated (what is the // correct thing to do), but native widgets would cause a repaint regardless // of that. Comment this out if you believe in correct apps if ((child.flags & IS_NATIVE_LIKE) != 0) child.repaint(); } // inherit parent attributes (if not overriden by child) if ((flags & (IS_PARENT_SHOWING | IS_VISIBLE)) == (IS_PARENT_SHOWING | IS_VISIBLE)) { child.flags |= IS_PARENT_SHOWING; child.propagateParentShowing(false); } if ((child.flags & IS_BG_COLORED) == 0) child.propagateBgClr(bgClr); if ((child.flags & IS_FG_COLORED) == 0) child.propagateFgClr(fgClr); if ((child.flags & IS_FONTIFIED) == 0) child.propagateFont(font); // Some LayoutManagers track adding/removing components. Since this seems to be // done after a potential addNotify, inform them here // (wouldn't it be nice to have a single LayoutManager interface?) if (layoutm != null) { if (layoutm instanceof LayoutManager2) { ((LayoutManager2) layoutm).addLayoutComponent(child, constraints); } if (constraints instanceof String) { layoutm.addLayoutComponent((String) constraints, child); } } if ((cntrListener != null) || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0) { AWTEvent.sendEvent( ContainerEvt.getEvent(this, ContainerEvent.COMPONENT_ADDED, child), false); } } }
private void dispatchEvent(MouseEvent me) { Component src = me.getComponent(); comp.dispatchEvent(SwingUtilities.convertMouseEvent(src, me, comp)); src.repaint(); }
/** * Invoked when the animated icon indicates that it is time for a repaint. * * @param context Component to refresh * @param key Substructure identification key */ protected void repaint(Component context, Object key) { Rectangle rect = getRepaintRect(context, key); if (rect != null) { context.repaint(rect.x, rect.y, rect.width, rect.height); } }
public boolean actionControlReceived(Action action) { String actionName = action.getName(); boolean ret = false; if (actionName.equals("GetPower") == true) { String state = getPowerState(); Argument powerArg = action.getArgument("Power"); powerArg.setValue(state); ret = true; } if (actionName.equals("SetPower") == true) { Argument powerArg = action.getArgument("Power"); String state = powerArg.getValue(); setPowerState(state); state = getPowerState(); Argument resultArg = action.getArgument("Result"); resultArg.setValue(state); ret = true; } comp.repaint(); return ret; }