/** Creates a new view. */ public NetView() { initComponents(); scrollPane.setLayout(new PlacardScrollPaneLayout()); scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); setEditor(new DefaultDrawingEditor()); undo = new UndoRedoManager(); view.setDrawing(createDrawing()); view.getDrawing().addUndoableEditListener(undo); initActions(); undo.addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { setHasUnsavedChanges(undo.hasSignificantEdits()); } }); ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); JPanel placardPanel = new JPanel(new BorderLayout()); javax.swing.AbstractButton pButton; pButton = ButtonFactory.createZoomButton(view); pButton.putClientProperty("Quaqua.Button.style", "placard"); pButton.putClientProperty("Quaqua.Component.visualMargin", new Insets(0, 0, 0, 0)); pButton.setFont(UIManager.getFont("SmallSystemFont")); placardPanel.add(pButton, BorderLayout.WEST); toggleGridButton = pButton = ButtonFactory.createToggleGridButton(view); pButton.putClientProperty("Quaqua.Button.style", "placard"); pButton.putClientProperty("Quaqua.Component.visualMargin", new Insets(0, 0, 0, 0)); pButton.setFont(UIManager.getFont("SmallSystemFont")); labels.configureToolBarButton(pButton, "view.toggleGrid.placard"); placardPanel.add(pButton, BorderLayout.EAST); scrollPane.add(placardPanel, JScrollPane.LOWER_LEFT_CORNER); toggleGridButton.setSelected(preferences.getBoolean("view.gridVisible", false)); view.setScaleFactor(preferences.getDouble("view.scaleFactor", 1d)); view.addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if ("scaleFactor".equals(name)) { preferences.putDouble("view.scaleFactor", (Double) evt.getNewValue()); firePropertyChange("scaleFactor", evt.getOldValue(), evt.getNewValue()); } } }); }
/** Creates a new instance. */ public TextFigure() { this( ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels") .getString("TextFigure.defaultText")); }
/** Creates a new instance. */ public LoadAction(Application app) { super(app); ResourceBundleUtil labels = ResourceBundleUtil.getLAFBundle("org.jhotdraw.app.Labels"); labels.configureAction(this, "open"); }
/** Creates a new instance. */ public SaveAsAction(Application app) { super(app, true); ResourceBundleUtil labels = ResourceBundleUtil.getLAFBundle("org.jhotdraw.app.Labels"); labels.configureAction(this, ID); }
/** * Displays a progress indicator and then invokes <code>loadDrawing</code> on a worker thread. * Displays the drawing panel when done successfully. Displays an error message when done * unsuccessfully. * * @see #loadDrawing */ @Override public final void init() { // set the language of the applet if (getParameter("Locale") != null) { Locale.setDefault(new Locale(getParameter("Locale"))); } final ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.samples.svg.Labels"); // Set look and feel // ----------------- try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Throwable e) { // Do nothing. // If we can't set the desired look and feel, UIManager does // automaticaly the right thing for us. } // Set our own popup factory, because the one that comes with Mac OS X // creates translucent popups which is not useful for color selection // using pop menus. try { PopupFactory.setSharedInstance(new PopupFactory()); } catch (Throwable e) { // If we can't set the popup factory, we have to use what is there. } // Display a progress indicator while we are loading the drawing // ---------------------------------------------------------- Container c = getContentPane(); final ProgressIndicator progress = new ProgressIndicator(getName(), labels.getString("progressInitializing")); c.add(progress); progress.revalidate(); // Load the drawing using a worker thread // -------------------------------------- new Worker<Drawing>() { @Override protected Drawing construct() throws Exception { Thread t = new Thread() { @Override public void run() { try { drawingComponent = createDrawingComponent(); } catch (Throwable t) { t.printStackTrace(); } } }; t.start(); try { progress.setNote(labels.getString("progressLoading")); Drawing drawing = loadDrawing(progress); progress.setNote(labels.getString("progressOpeningEditor")); progress.setIndeterminate(true); return drawing; } finally { t.join(); } } @Override protected void done(Drawing result) { Container c = getContentPane(); c.removeAll(); c.setLayout(new BorderLayout()); c.add(drawingComponent.getComponent()); initComponents(); if (result != null) { setDrawing(result); } drawingComponent.revalidate(); ((JComponent) c).revalidate(); } @Override protected void failed(Throwable error) { Drawing d = createDrawing(); String message = (error.getMessage() == null) ? error.toString() : error.getMessage(); SVGTextAreaFigure txt = new SVGTextAreaFigure( labels.getFormatted("messageLoadFailed", getParameter("DrawingURL"), message)); txt.setBounds(new Point2D.Double(0, 0), new Point2D.Double(getWidth(), getHeight())); d.add(txt); done(d); /* Container c = getContentPane(); c.setLayout(new BorderLayout()); c.removeAll(); Throwable error = result; error.printStackTrace(); String message = (error.getMessage() == null) ? error.toString() : error.getMessage(); MessagePanel mp = new MessagePanel( UIManager.getIcon("OptionPane.errorIcon"), labels.getFormatted("messageLoadFailed", htmlencode(getParameter("DrawingURL")), htmlencode(message))); c.add(mp); mp.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if ("close".equals(evt.getActionCommand())) { close(); } } }); mp.revalidate(); */ } @Override protected void finished() { long end = System.currentTimeMillis(); System.out.println("AbstractDrawingApplet startup latency:" + (end - start)); } }.start(); }