/** Notifies all views of a data reference change. */ public void init() { final Data data = initHistory(gui.context); if (data != null) { // if a large database is opened, the user is asked if complex /// visualizations should be closed first final long size = data.meta.dbsize(); boolean open = false; for (final View v : view) open |= v.visible() && v.db(); if (open && size > LARGEDB && BaseXDialog.confirm(gui, Util.info(H_LARGE_DB, Performance.format(size)))) { for (final View v : view) if (v.visible() && v.db()) v.visible(false); } } else { // database closed: close open dialogs for (final Window w : gui.getOwnedWindows()) { if (w.isVisible() && w instanceof BaseXDialog) ((BaseXDialog) w).cancel(); } } gui.context.focused = -1; for (final View v : view) v.refreshInit(); gui.layoutViews(); gui.setTitle(data != null ? data.meta.name : null); }
public static void main(String[] args) { GUI dialog = new GUI(); dialog.pack(); dialog.setVisible(true); System.exit(0); }
@Override public void execute(final GUI gui) { final boolean rt = gui.gprop.invert(GUIProp.FILTERRT); gui.stop(); // refresh buttons in input bar gui.refreshControls(); // refresh editor buttons gui.editor.refreshMark(); final Context ctx = gui.context; final boolean root = ctx.root(); final Data data = ctx.data(); if (!rt) { if (!root) { gui.notify.context(new Nodes(0, data), true, null); gui.notify.mark(ctx.current(), null); } } else { if (root) { gui.notify.mark(new Nodes(data), null); } else { final Nodes mark = ctx.marked; ctx.marked = new Nodes(data); gui.notify.context(mark, true, null); } } }
public void actionPerformed(ActionEvent e) { // Return a fileName String fileName = "WeAreTheChampions"; String songorAuthor = "S"; gui.setAuthororSinger(songorAuthor); gui.updateFileName(fileName); gui.updateState(true); }
private void apply() { int size = getPanelsSize(); for (int i = 0; i < size; i++) { getPanel(i).apply(); } // System.out.println("apply from dialog"); gui.getTopPane().draw(); }
/** * Sets the current theme. * * @param theme the new theme */ public static void setTheme(Themes theme) { currentTheme = theme; System.out.println(theme.getName()); // activate current theme GUI.resetLookAndFeel(); // wipes the slate clean theme.doColoring(); GUI.setNimbusLookAndFeel(); // puts nimbus back on }
@Override public void execute(final GUI gui) { gui.gprop.invert(GUIProp.EXECRT); gui.stop(); // refresh buttons in input bar gui.refreshControls(); // refresh editor buttons gui.editor.refreshMark(); }
/** run method for class */ public void run() { GUI gui = (GUI) registeredObject; GPane pane = gui.getTopPane(); pane.setMode(GPane.DRAW_MARKER_MODE); super.setSelected(true); gui.getNotifier().firePaneEvent(this); gui.getProgressMeter().getPanel().repaint(); }
public static void next() throws Exception { if (REPEATMEDIA == ACTIVE) { REPEATMEDIA = UNACTIVE; GUI.getInstance().repeatTrack.setState(false); } GUI.getInstance().jTable.setValueAt(" ", CURRENTINDEXMEDIA, 0); if (CURRENTINDEXMEDIA == CURRENTPLAYLIST.getNumberOfMedia() - 1) { if (REPEATPLAYLIST == ACTIVE) { CURRENTINDEXMEDIA = 0; play(CURRENTPLAYLIST, CURRENTINDEXMEDIA); } } else { CURRENTINDEXMEDIA++; play(CURRENTPLAYLIST, CURRENTINDEXMEDIA); } }
/** Notifies all views of updates in the data structure. */ public void update() { final Data data = initHistory(gui.context); if (data == null) return; gui.context.marked = new Nodes(data); for (final View v : view) if (v.visible()) v.refreshUpdate(); gui.refreshControls(); }
/** * Method to set the boolean value of whether the menu action removeObject is enabled or not * depending if the right click occured on an object. */ public void update() { if (gui.getGMap().getGDraw().getSelected().getSize() == 0) { removeObject.setEnabled(false); } else { removeObject.setEnabled(true); } }
/** * Notifies all views of a context change. * * @param nodes new context set (may be {@code null} if root nodes are addressed) * @param quick quick switch * @param vw the calling view */ public void context(final Nodes nodes, final boolean quick, final View vw) { final Context ctx = gui.context; // add new entry if current node set has not been cached yet final Nodes newn = nodes.checkRoot(); final Nodes empty = new Nodes(new int[0], ctx.data(), ctx.marked.ftpos); final Nodes curr = quick ? ctx.current() : null; final Nodes cmp = quick ? curr : ctx.marked; if (cont[hist] == null ? cmp != null : cmp == null || !cont[hist].sameAs(cmp)) { checkHist(); if (quick) { // store history entry queries[hist] = ""; marked[hist] = new Nodes(ctx.data()); // add current entry cont[++hist] = curr; } else { // store history entry final String in = gui.input.getText(); queries[hist] = in; marked[hist] = ctx.marked; // add current entry cont[++hist] = newn; queries[hist] = in; marked[hist] = empty; } histsize = hist; } ctx.set(newn, empty); for (final View v : view) if (v != vw && v.visible()) v.refreshContext(true, quick); gui.refreshControls(); }
protected JButton createButton(String icon, String text, String command) { if (listener == null) { listener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(ADD)) { addItem(); } else if (e.getActionCommand().equals(REMOVE)) { removeItem(); } else if (e.getActionCommand().equals(UP)) { moveItemUp(); } else if (e.getActionCommand().equals(DOWN)) { moveItemDown(); } } }; } ToolbarButton button = new ToolbarButton(); if (icon != null) { button.setIcon(GUI.getIcon(icon)); } if (text != null) { button.setText(text); } else { button.setMargin(GUI.noInsets); button.setToolTipText(command); } button.setEnabled(false); button.setActionCommand(command); button.addActionListener(listener); buttons.put(command, button); return button; }
/** * Notifies all views of a selection change. * * @param mark marked nodes * @param vw the calling view */ public void mark(final Nodes mark, final View vw) { final Context ctx = gui.context; ctx.marked = mark; for (final View v : view) if (v != vw && v.visible()) v.refreshMark(); gui.filter.setEnabled(mark.size() != 0); gui.refreshControls(); }
public Channels() { super("Channels"); if (instance != null) { instance.toFront(); return; } WindowManager.addWindow(this); instance = this; GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); int y = 0; c.gridx = 0; c.gridy = y++; c.gridwidth = 1; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; int margin = 32; if (IJ.isMacOSX()) margin = 20; c.insets = new Insets(10, margin, 10, margin); choice = new Choice(); for (int i = 0; i < modes.length; i++) choice.addItem(modes[i]); choice.select(0); choice.addItemListener(this); add(choice, c); CompositeImage ci = getImage(); int nCheckBoxes = ci != null ? ci.getNChannels() : 3; if (nCheckBoxes > CompositeImage.MAX_CHANNELS) nCheckBoxes = CompositeImage.MAX_CHANNELS; checkbox = new Checkbox[nCheckBoxes]; for (int i = 0; i < nCheckBoxes; i++) { checkbox[i] = new Checkbox("Channel " + (i + 1), true); c.insets = new Insets(0, 25, i < nCheckBoxes - 1 ? 0 : 10, 5); c.gridy = y++; add(checkbox[i], c); checkbox[i].addItemListener(this); } c.insets = new Insets(0, 15, 10, 15); c.fill = GridBagConstraints.NONE; c.gridy = y++; moreButton = new Button(moreLabel); moreButton.addActionListener(this); add(moreButton, c); update(); pm = new PopupMenu(); for (int i = 0; i < menuItems.length; i++) addPopupItem(menuItems[i]); add(pm); addKeyListener(IJ.getInstance()); // ImageJ handles keyboard shortcuts setResizable(false); pack(); if (location == null) { GUI.center(this); location = getLocation(); } else setLocation(location); show(); }
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. }
@Override public void actionPerformed(ActionEvent e) { parent.newGame( (int) numAI.getValue(), AIPlayer.Difficulty.valueOf(chooseDifficulty.getSelection().getActionCommand())); this.dispose(); }
public void paintBackground(Container parent, Graphics g, int x, int y, int height) { if (getBackgroundColor() != null) { g.setColor(getBackgroundColor()); g.fillRect(x, y, getWidth(), height); } if (getBackgroundImage() != null) { GUI.tileImage(getBackgroundImage(), g, x, y, getWidth(), height); } }
/** Check mandatory and isEditable to set color settings. */ protected void performFlags() { Assert.isNotNull(moneyField); Assert.isNotNull(flagLabel); if (isReadonly()) { moneyField.setBackground(SystemColor.control); flagLabel.setIcon(GUI.getOptionalIcon()); } else { // @todo find appropriate system color moneyField.setBackground(Color.white); if (mandatory && getObjectValue() == null) { flagLabel.setIcon(GUI.getMandatoryIcon()); } else { flagLabel.setIcon(GUI.getOptionalIcon()); } } }
/** * Creates and shows an alert dialog. * * @param frame the parent frame. Can be null. * @param whatToSay the body of the dialog. * @param title the title of the dialog. * @param iconPath the icon's name (x.png) */ public static void showDialog(JFrame frame, String whatToSay, String title, String iconPath) { JOptionPane.showMessageDialog( frame, // parent whatToSay, // text title, // title JOptionPane.INFORMATION_MESSAGE, // mesage type GUI.createImageIcon(iconPath) // icon ); }
public ResourceIcon(Resource r, int width, int height, Component painter) { setSize(width, height); // StatusLabel.setVisible(false); // add(StatusLabel); // loadResource(r); mResource = r; mPainter = painter; if (DEBUG.IMAGE) out("Constructed " + width + "x" + height + " " + r + " painter=" + GUI.namex(painter)); }
public void readFile() throws IOException { try { FileInputStream fstream = new FileInputStream("dataIn.txt"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; int memi = -1; int strLineMemory = 59; while ((strLine = br.readLine()) != null) { t.data[strLineMemory++][1] = String.valueOf(strLine); memi++; size++; while ((strLine = br.readLine()) != null && !strLine.startsWith("*")) { String[] arr = strLine.split(" "); String command = arr[0]; String operand = arr[1]; toMemory(command, operand, memarray[memi]); memarray[memi] = memarray[memi] + 2; System.out.printf("%s %s ", command, operand); } } in.close(); } catch (Exception e) { // Catch exception if any System.err.println("Error: " + e.getMessage()); } MOSMain mos = new MOSMain(); mos.planner(); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); t.setSize(830, 800); t.setVisible(true); t.setTitle("Printer"); sortTime(); }
/** * The GPropertiesDialog class constructor. * * @param gui the GUI class */ public GPropertiesDialog(GUI gui) { // superclass constructor super(gui, "Properties", false); objects = new ObjectContainer(); // gui this.gui = gui; // set the fixed size setSize(260, 350); setResizable(false); setLayout(null); // set up panels for stuff pane = new JTabbedPane(); // add the tabbed panel tabbedPanePanel = new JPanel(); tabbedPanePanel.add(pane); tabbedPanePanel.setLayout(null); this.getContentPane().add(tabbedPanePanel); tabbedPanePanel.setBounds(0, 0, this.getWidth(), 280); pane.setBounds(0, 0, tabbedPanePanel.getWidth(), tabbedPanePanel.getHeight()); // set up buttons apply = new JButton("Apply"); apply.setBounds(150, 290, 80, 26); this.getContentPane().add(apply); close = new JButton("Close"); close.setBounds(50, 290, 80, 26); this.getContentPane().add(close); addPanel(new GPropertiesPanelCustomObject(gui.getGMap()), "Object"); // add listeners addMouseListener(this); apply.addItemListener(this); apply.addActionListener(this); close.addItemListener(this); close.addActionListener(this); }
@Override public void execute(final GUI gui) { final StringBuilder sb = new StringBuilder(); final Nodes n = gui.context.copied; for (int i = 0; i < n.size(); ++i) { if (i > 0) sb.append(','); sb.append(openPre(n, i)); } gui.context.copied = null; gui.execute(new XQuery("insert nodes (" + sb + ") into " + openPre(gui.context.marked, 0))); }
@Override public void execute(final GUI gui) { final Nodes n = gui.context.marked; final DialogEdit edit = new DialogEdit(gui, n.pres[0]); if (!edit.ok()) return; String rename = null; String replace = null; final int k = edit.kind; if (k == Data.ELEM || k == Data.PI || k == Data.ATTR) { rename = edit.result.get(0); if (k != Data.ELEM) replace = edit.result.get(1); } else { replace = edit.result.get(0); } if (rename != null) gui.execute(new XQuery("rename node " + openPre(n, 0) + " as " + quote(rename))); if (replace != null) gui.execute( new XQuery("replace value of node " + openPre(n, 0) + " with " + quote(replace))); }
public Point getPreferredLocation() { Rectangle maxBounds = GUI.getMaxWindowBounds(); int ijX = Prefs.getInt(IJ_X, -99); int ijY = Prefs.getInt(IJ_Y, -99); if (ijX >= maxBounds.x && ijY >= maxBounds.y && ijX < (maxBounds.x + maxBounds.width - 75)) return new Point(ijX, ijY); Dimension tbsize = toolbar.getPreferredSize(); int ijWidth = tbsize.width + 10; double percent = maxBounds.width > 832 ? 0.8 : 0.9; ijX = (int) (percent * (maxBounds.width - ijWidth)); if (ijX < 10) ijX = 10; return new Point(ijX, maxBounds.y); }
@Override public void execute(final GUI gui) { if (!BaseXDialog.confirm(gui, DELETE_NODES)) return; final StringBuilder sb = new StringBuilder(); final Nodes n = gui.context.marked; for (int i = 0; i < n.size(); ++i) { if (i > 0) sb.append(','); sb.append(openPre(n, i)); } gui.context.marked = new Nodes(n.data); gui.context.copied = null; gui.context.focused = -1; gui.execute(new XQuery("delete nodes (" + sb + ')')); }
public ModelElementsPropertiesPanel() { setLayout(new BorderLayout(GUI.HorizontalWidgetDistance, 0)); setBorder(GUI.getEmptyPanelBorder()); toolbar = createToolbar(); if (toolbar != null) { add(toolbar, BorderLayout.NORTH); } Component details = createDetailsPanel(); if (details != null) { add(details); } Component list = createListPanel(); if (list != null) { add(list, BorderLayout.WEST); } }
/** * Moves around in the internal history and notifies all views of a context change. * * @param forward move forward or backward */ public void hist(final boolean forward) { final Context ctx = gui.context; final String query; if (forward) { if (hist == histsize) return; query = queries[++hist]; } else { if (hist == 0) return; marked[hist] = ctx.marked; query = queries[--hist]; } ctx.set(cont[hist], marked[hist]); gui.input.setText(query); for (final View v : view) if (v.visible()) v.refreshContext(forward, false); gui.refreshControls(); }
/** * Draws an emblem (based on current theme) in the bottom left of the given component. Call this * in paintComponent() of the component. * * @param component the component to draw on * @param g the Graphics object from paintComponent() */ public static void drawEmblem(JComponent component, Graphics g) { Themes currentTheme = Themes.getCurrentTheme(); ImageIcon image = GUI.createImageIcon("translucent/" + currentTheme.getImageIconPath()); /*if(Themes.getCurrentTheme() == Themes.SNOW){ image = GUI.createImageIcon("translucent/snow.png"); }*/ int imageWidth = image.getIconWidth(); int imageHeight = image.getIconHeight(); // top left corner of where to start drawing int topLeftX = component.getWidth() - imageWidth; // x (horizontal) coordinate int topLeftY = component.getHeight() - imageHeight; // y (vertical) coordinate // draw in bottom right corner g.drawImage(image.getImage(), topLeftX, topLeftY, (java.awt.image.ImageObserver) null); // g.drawImage(image.getImage(), 0,0, (java.awt.image.ImageObserver)null); }