/**
   * Default constructor.
   *
   * @param main reference to the main window
   */
  public DialogInsert(final GUI main) {
    super(main, INSERTTITLE);

    label1 = new BaseXLabel(EDITNAME + COLS, true, true).border(0, 0, 0, 0);
    label2 = new BaseXLabel(EDITVALUE + COLS, true, true).border(0, 0, 0, 0);

    input1 = new BaseXTextField(this);
    input1.addKeyListener(keys);
    BaseXLayout.setWidth(input1, 320);

    input2 = new BaseXEditor(true, this);
    input2.setFont(GUIConstants.mfont);
    input2.addKeyListener(keys);
    BaseXLayout.setWidth(input2, 320);

    final BaseXBack knd = new BaseXBack(new TableLayout(1, 5));
    final ButtonGroup group = new ButtonGroup();

    final ActionListener al =
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            change(e.getSource());
          }
        };

    final int lkind = gui.gprop.num(GUIProp.LASTINSERT);
    radio = new BaseXRadio[EDITKIND.length];
    for (int i = 1; i < EDITKIND.length; ++i) {
      radio[i] = new BaseXRadio(EDITKIND[i], false, this);
      radio[i].addActionListener(al);
      radio[i].setSelected(i == lkind);
      radio[i].addKeyListener(keys);
      group.add(radio[i]);
      knd.add(radio[i]);
    }
    set(knd, BorderLayout.NORTH);

    back = new BaseXBack(10, 0, 0, 0);
    set(back, BorderLayout.CENTER);

    final BaseXBack pp = new BaseXBack(new BorderLayout());
    info = new BaseXLabel(" ").border(8, 0, 2, 0);
    pp.add(info, BorderLayout.WEST);

    buttons = okCancel(this);
    pp.add(buttons, BorderLayout.EAST);
    set(pp, BorderLayout.SOUTH);

    setResizable(true);
    change(radio[lkind]);

    action(null);
    finish(null);
  }
Exemple #2
0
  /**
   * Constructor.
   *
   * @param win parent window
   */
  public BaseXPassword(final Window win) {
    BaseXLayout.setWidth(this, BaseXTextField.DWIDTH);
    BaseXLayout.addInteraction(this, win);

    if (!(win instanceof BaseXDialog)) return;

    addKeyListener(((BaseXDialog) win).keys);
    addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(final MouseEvent e) {
            BaseXLayout.focus(e.getComponent());
          }
        });
  }
Exemple #3
0
 /**
  * Adds a text field.
  *
  * @param pos position
  */
 private void addInput(final int pos) {
   final BaseXTextField txt = new BaseXTextField(gui);
   BaseXLayout.setWidth(txt, COMPW);
   BaseXLayout.setHeight(txt, txt.getFont().getSize() + 11);
   txt.setMargin(new Insets(0, 0, 0, 10));
   txt.addKeyListener(
       new KeyAdapter() {
         @Override
         public void keyReleased(final KeyEvent e) {
           query(false);
         }
       });
   txt.addKeyListener(main);
   panel.add(txt, pos);
 }
Exemple #4
0
 /**
  * Constructor.
  *
  * @param l label of the menu item
  * @param k key shortcut
  * @param h help string
  * @param d requires a database to be opened
  * @param c displays a checkbox, indicating the current selection state
  */
 GUICommands(final String l, final String k, final String h, final boolean d, final boolean c) {
   label = l;
   key = k;
   help = BaseXLayout.addShortcut(h, k);
   data = d;
   checked = c;
 }
Exemple #5
0
 /**
  * Adds a combobox.
  *
  * @param values combobox values
  * @param pos position
  */
 private void addCombo(final String[] values, final int pos) {
   final BaseXCombo cm = new BaseXCombo(gui, values);
   BaseXLayout.setWidth(cm, COMPW);
   cm.addActionListener(this);
   cm.addKeyListener(main);
   panel.add(cm, pos);
 }
Exemple #6
0
 /**
  * Adds a combobox.
  *
  * @param min minimum value
  * @param max maximum value
  * @param pos position
  * @param itr integer flag
  */
 private void addSlider(final double min, final double max, final int pos, final boolean itr) {
   final BaseXDSlider sl = new BaseXDSlider(gui, min, max, this);
   BaseXLayout.setWidth(sl, COMPW + BaseXDSlider.LABELW);
   sl.itr = itr;
   sl.addKeyListener(main);
   panel.add(sl, pos);
 }
Exemple #7
0
  /**
   * Copies the selected text to the clipboard.
   *
   * @return true if text was copied
   */
  private boolean copy() {
    final String txt = editor.copy();
    if (txt.isEmpty()) return false;

    // copy selection to clipboard
    BaseXLayout.copy(txt);
    return true;
  }
Exemple #8
0
 /**
  * Returns the clipboard text.
  *
  * @return text
  */
 static final String clip() {
   // copy selection to clipboard
   final Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
   final Transferable tr = clip.getContents(null);
   if (tr != null) {
     for (final Object o : BaseXLayout.contents(tr)) return o.toString();
   }
   return "";
 }
Exemple #9
0
 /**
  * Paints the input box.
  *
  * @param g graphics reference
  * @param x x position
  * @param y y position
  * @param w width
  * @param h height
  */
 void paint(final Graphics g, final int x, final int y, final int w, final int h) {
   g.setColor(GUIConstants.color4);
   g.drawRect(x, y - 1, w - 1, h);
   g.setColor(Color.black);
   g.setFont(GUIConstants.font);
   g.drawString(text, x + 5, y + h - 7);
   final int xx = x + BaseXLayout.width(g, text.substring(0, pos)) + 5;
   if (flashing) g.drawLine(xx, y + 1, xx, y + h - 5);
 }
Exemple #10
0
  /**
   * Constructor.
   *
   * @param main reference to the main window
   */
  GUIStatus(final AGUI main) {
    super(main);
    BaseXLayout.setHeight(this, getFont().getSize() + 6);
    addMouseListener(this);
    addMouseMotionListener(this);

    layout(new BorderLayout(4, 0));
    label = new BaseXLabel(OK).border(0, 4, 0, 0);
    add(label, BorderLayout.CENTER);
    add(new BaseXMem(main, true), BorderLayout.EAST);
  }
Exemple #11
0
 /**
  * Returns the clipboard text.
  *
  * @return text
  */
 private static String clip() {
   // copy selection to clipboard
   final Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
   final Transferable tr = clip.getContents(null);
   if (tr != null) {
     final ArrayList<Object> contents = BaseXLayout.contents(tr);
     if (!contents.isEmpty()) return contents.get(0).toString();
   } else {
     Util.debug("Clipboard has no contents.");
   }
   return null;
 }
Exemple #12
0
 /**
  * Constructor.
  *
  * @param root root node
  * @param w window reference
  */
 public BaseXTree(final DefaultMutableTreeNode root, final Window w) {
   super(root);
   BaseXLayout.addInteraction(this, w);
   setLargeModel(true);
   addMouseListener(
       new MouseAdapter() {
         @Override
         public void mousePressed(final MouseEvent e) {
           if (!e.isShiftDown()) setSelectionRow(getClosestRowForLocation(e.getX(), e.getY()));
         }
       });
 }
Exemple #13
0
  /**
   * Constructor.
   *
   * @param win parent reference
   * @param mouse mouse interaction
   */
  public BaseXMem(final Window win, final boolean mouse) {
    super(win);
    BaseXLayout.setWidth(this, DWIDTH);
    BaseXLayout.setHeight(this, getFont().getSize() + 6);
    if (mouse) {
      setCursor(CURSORHAND);
      addMouseListener(this);
      addMouseMotionListener(this);
    }

    final Thread t =
        new Thread() {
          @Override
          public void run() {
            repaint();
            Performance.sleep(500);
          }
        };
    t.setDaemon(true);
    t.start();
  }
Exemple #14
0
 /**
  * Constructor.
  *
  * @param view project view
  */
 ProjectList(final ProjectView view) {
   project = view;
   setBorder(BaseXLayout.border(4, 4, 4, 4));
   setCellRenderer(new CellRenderer());
   addMouseListener(
       new MouseAdapter() {
         @Override
         public void mousePressed(final MouseEvent e) {
           if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) open();
         }
       });
   new BaseXPopup(this, view.gui, commands);
 }
Exemple #15
0
 /** Adds a tab for creating new tabs. */
 private void addCreateTab() {
   final BaseXButton add = tabButton("e_new");
   add.setRolloverIcon(BaseXLayout.icon("e_new2"));
   add.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(final ActionEvent e) {
           addTab();
           refreshControls(true);
         }
       });
   tabs.add(new BaseXBack(), add, 0);
   tabs.setEnabledAt(0, false);
 }
Exemple #16
0
  /**
   * Default constructor.
   *
   * @param main reference to the main window
   */
  private DialogBindings(final GUI main) {
    super(main, EXTERNAL_VARIABLES, false);

    final int cl = context.length;
    for (int c = 0; c < cl; c++) {
      context[c] = new BaseXTextField(this);
      BaseXLayout.setWidth(context[c], c % 2 == 0 ? 80 : 200);
    }

    final BaseXBack table = new BaseXBack(new TableLayout((2 + cl) / 2, 2, 8, 4));
    table.add(new BaseXLabel(NAME + COLS, false, true));
    table.add(new BaseXLabel(VALUE + COLS, false, true));
    for (final BaseXTextField ctx : context) table.add(ctx);
    set(table, BorderLayout.CENTER);

    fill();
    finish(gui.gopts.get(GUIOptions.BINDINGSLOC));
  }
Exemple #17
0
  /**
   * Adds a new editor tab.
   *
   * @return editor reference
   */
  EditorArea addTab() {
    final EditorArea edit = new EditorArea(this, newTabFile());
    edit.setFont(GUIConstants.mfont);

    final BaseXBack tab = new BaseXBack(new BorderLayout(10, 0)).mode(Fill.NONE);
    tab.add(edit.label, BorderLayout.CENTER);

    final BaseXButton close = tabButton("e_close");
    close.setRolloverIcon(BaseXLayout.icon("e_close2"));
    close.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            close(edit);
          }
        });
    tab.add(close, BorderLayout.EAST);

    tabs.add(edit, tab, tabs.getComponentCount() - 2);
    return edit;
  }
Exemple #18
0
  @Override
  public void paintComponent(final Graphics g) {
    super.paintComponent(g);

    final int w = getWidth();
    final int h = getHeight();
    final int hh = h / 2;
    final int s = (int) (3 * GUIConstants.SCALE);

    g.setColor(hasFocus() ? GUIConstants.BACK : GUIConstants.lgray);
    g.fillRect(0, hh - s, w, s * 2 - 1);
    g.setColor(GUIConstants.TEXT);
    g.drawLine(0, hh - s, w, hh - s);
    g.drawLine(0, hh - s, 0, hh + s - 1);
    g.setColor(GUIConstants.gray);
    g.drawLine(w - 1, hh - s, w - 1, hh + s - 1);
    g.drawLine(0, hh + s - 1, w, hh + s - 1);

    final double x = (value - min) * (w - SLIDERW) / (max - min);
    BaseXLayout.drawCell(g, (int) x, (int) (x + SLIDERW), hh - s * 2, hh + s * 2, oldValue != -1);
  }
  /**
   * Activates the specified radio button.
   *
   * @param src button reference
   */
  void change(final Object src) {
    int n = 0;
    for (int r = 0; r < radio.length; ++r) if (src == radio[r]) n = r;
    BaseXLayout.setHeight(input2, n == Data.ATTR ? 25 : 200);

    back.removeAll();
    back.layout(new BorderLayout(0, 4));
    if (n != Data.TEXT && n != Data.COMM) {
      final BaseXBack b = new BaseXBack(new BorderLayout(0, 4));
      b.add(label1, BorderLayout.NORTH);
      b.add(input1, BorderLayout.CENTER);
      back.add(b, BorderLayout.NORTH);
    }
    if (n != Data.ELEM) {
      final BaseXBack b = new BaseXBack(new BorderLayout(0, 4));
      b.add(label2, BorderLayout.NORTH);
      b.add(input2, BorderLayout.CENTER);
      back.add(b, BorderLayout.CENTER);
    }
    pack();
  }
Exemple #20
0
  /**
   * Default constructor.
   *
   * @param man view manager
   */
  public EditorView(final ViewNotifier man) {
    super(EDITORVIEW, man);
    if (Prop.langright) applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

    border(6, 6, 6, 6).layout(new BorderLayout(0, 2)).setFocusable(false);

    header = new BaseXLabel(EDITOR, true, false);

    final BaseXButton srch = new BaseXButton(gui, "search", H_REPLACE);
    final BaseXButton openB = BaseXButton.command(GUICommands.C_EDITOPEN, gui);
    final BaseXButton saveB = new BaseXButton(gui, "save", H_SAVE);
    hist = new BaseXButton(gui, "hist", H_RECENTLY_OPEN);

    final BaseXBack buttons = new BaseXBack(Fill.NONE);
    buttons.layout(new TableLayout(1, 4, 1, 0));
    buttons.add(srch);
    buttons.add(openB);
    buttons.add(saveB);
    buttons.add(hist);

    final BaseXBack b = new BaseXBack(Fill.NONE).layout(new BorderLayout(8, 0));
    if (Prop.langright) {
      b.add(header, BorderLayout.EAST);
      b.add(buttons, BorderLayout.WEST);
    } else {
      b.add(header, BorderLayout.CENTER);
      b.add(buttons, BorderLayout.EAST);
    }
    add(b, BorderLayout.NORTH);

    tabs = new BaseXTabs(gui);
    tabs.setFocusable(false);
    final SearchEditor se = new SearchEditor(gui, tabs, null).button(srch);
    search = se.panel();
    addCreateTab();
    add(se, BorderLayout.CENTER);

    // status and query pane
    search.editor(addTab(), false);

    info = new BaseXLabel().setText(OK, Msg.SUCCESS);
    pos = new BaseXLabel(" ");
    posCode.invokeLater();

    stop = new BaseXButton(gui, "stop", H_STOP_PROCESS);
    stop.addKeyListener(this);
    stop.setEnabled(false);

    go = new BaseXButton(gui, "go", H_EXECUTE_QUERY);
    go.addKeyListener(this);

    filter = BaseXButton.command(GUICommands.C_FILTER, gui);
    filter.addKeyListener(this);
    filter.setEnabled(false);

    final BaseXBack status = new BaseXBack(Fill.NONE).layout(new BorderLayout(4, 0));
    status.add(info, BorderLayout.CENTER);
    status.add(pos, BorderLayout.EAST);

    final BaseXBack query = new BaseXBack(Fill.NONE).layout(new TableLayout(1, 3, 1, 0));
    query.add(stop);
    query.add(go);
    query.add(filter);

    final BaseXBack south = new BaseXBack(Fill.NONE).border(4, 0, 0, 0);
    south.layout(new BorderLayout(8, 0));
    south.add(status, BorderLayout.CENTER);
    south.add(query, BorderLayout.EAST);
    add(south, BorderLayout.SOUTH);

    refreshLayout();

    // add listeners
    saveB.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            final JPopupMenu pop = new JPopupMenu();
            final StringBuilder mnem = new StringBuilder();
            final JMenuItem sa = GUIMenu.newItem(GUICommands.C_EDITSAVE, gui, mnem);
            final JMenuItem sas = GUIMenu.newItem(GUICommands.C_EDITSAVEAS, gui, mnem);
            GUICommands.C_EDITSAVE.refresh(gui, sa);
            GUICommands.C_EDITSAVEAS.refresh(gui, sas);
            pop.add(sa);
            pop.add(sas);
            pop.show(saveB, 0, saveB.getHeight());
          }
        });
    hist.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            final JPopupMenu pm = new JPopupMenu();
            final ActionListener al =
                new ActionListener() {
                  @Override
                  public void actionPerformed(final ActionEvent ac) {
                    open(new IOFile(ac.getActionCommand()));
                  }
                };
            final StringList sl = new StringList();
            for (final EditorArea ea : editors()) sl.add(ea.file.path());
            for (final String en :
                new StringList().add(gui.gprop.strings(GUIProp.EDITOR)).sort(!Prop.WIN, true)) {
              final JMenuItem it = new JMenuItem(en);
              it.setEnabled(!sl.contains(en));
              pm.add(it).addActionListener(al);
            }
            pm.show(hist, 0, hist.getHeight());
          }
        });
    refreshHistory(null);
    info.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(final MouseEvent e) {
            EditorArea ea = getEditor();
            if (errFile != null) {
              ea = find(IO.get(errFile), false);
              if (ea == null) ea = open(new IOFile(errFile));
              tabs.setSelectedComponent(ea);
            }
            if (errPos == -1) return;
            ea.jumpError(errPos);
            posCode.invokeLater();
          }
        });
    stop.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            stop.setEnabled(false);
            go.setEnabled(false);
            gui.stop();
          }
        });
    go.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            getEditor().release(Action.EXECUTE);
          }
        });
    tabs.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(final ChangeEvent e) {
            final EditorArea ea = getEditor();
            if (ea == null) return;
            search.editor(ea, true);
            gui.refreshControls();
            posCode.invokeLater();
          }
        });

    BaseXLayout.addDrop(
        this,
        new DropHandler() {
          @Override
          public void drop(final Object file) {
            if (file instanceof File) open(new IOFile((File) file));
          }
        });
  }
Exemple #21
0
 /**
  * Sets the label borders.
  *
  * @param t top distance
  * @param l left distance
  * @param b bottom distance
  * @param r right distance
  * @return self reference
  */
 public final BaseXTree border(final int t, final int l, final int b, final int r) {
   setBorder(BaseXLayout.border(t, l, b, r));
   return this;
 }
Exemple #22
0
 /**
  * Constructor, setting default interactions.
  *
  * @param win parent reference, {@link BaseXDialog} or {@link GUI} instance
  */
 protected BaseXPanel(final Window win) {
   gui = win instanceof GUI ? (GUI) win : ((BaseXDialog) win).gui;
   BaseXLayout.addInteraction(this, win);
 }
Exemple #23
0
 /**
  * Creates a slider.
  *
  * @param option option
  * @return slider reference
  */
 private BaseXSlider newSlider(final NumberOption option) {
   final BaseXSlider slider = new BaseXSlider(0, MAXCOLOR, option, gui.gopts, this);
   BaseXLayout.setWidth(slider, 150);
   return slider;
 }
Exemple #24
0
 @Override
 public void execute() {
   BaseXLayout.copy(selectedValue());
 }
  @Override
  public void paintComponent(final Graphics g) {
    super.paintComponent(g);

    // skip if view is unavailable
    if (tdata.rows == null) return;

    gui.painting = true;
    g.setFont(GUIConstants.font);

    final int w = getWidth() - scroll.getWidth();
    final int h = getHeight();
    final int fsz = gui.gprop.num(GUIProp.FONTSIZE);

    final Context context = tdata.context;
    final Data data = context.data();
    final int focus = gui.context.focused;
    final int rfocus = tdata.getRoot(data, focus);
    int mpos = 0;

    final int nCols = tdata.cols.length;
    final int nRows = tdata.rows.size();
    final int rowH = tdata.rowH;

    final TableIterator ti = new TableIterator(data, tdata);
    final TokenBuilder[] tb = new TokenBuilder[nCols];
    for (int i = 0; i < nCols; ++i) tb[i] = new TokenBuilder();

    focusedString = null;
    final Nodes marked = context.marked;
    int l = scroll.pos() / rowH - 1;
    int posY = -scroll.pos() + l * rowH;

    while (++l < nRows && marked != null) {
      // skip when all visible rows have been painted or if data has changed
      if (posY > h || l >= tdata.rows.size()) break;
      posY += rowH;

      final int pre = tdata.rows.get(l);
      while (mpos < marked.size() && marked.list[mpos] < pre) ++mpos;

      // draw line
      g.setColor(GUIConstants.color2);
      g.drawLine(0, posY + rowH - 1, w, posY + rowH - 1);
      g.setColor(Color.white);
      g.drawLine(0, posY + rowH, w, posY + rowH);

      // verify if current node is marked or focused
      final boolean rm = mpos < marked.size() && marked.list[mpos] == pre;
      final boolean rf = pre == rfocus;
      final int col = rm ? rf ? 5 : 4 : 3;
      if (rm || rf) {
        g.setColor(GUIConstants.color(col));
        g.fillRect(0, posY - 1, w, rowH);
        g.setColor(GUIConstants.color(col + 4));
        g.drawLine(0, posY - 1, w, posY - 1);
      }
      g.setColor(Color.black);

      // skip drawing of text during animation
      if (rowH < fsz) continue;

      // find all row contents
      ti.init(pre);
      int fcol = -1;
      while (ti.more()) {
        final int c = ti.col;
        if (ti.pre == focus || data.parent(ti.pre, data.kind(ti.pre)) == focus) fcol = c;

        // add content to column (skip too long contents)...
        if (tb[c].size() < 100) {
          if (tb[c].size() != 0) tb[c].add("; ");
          tb[c].add(data.text(ti.pre, ti.text));
        }
      }

      // add dots if content is too long
      for (final TokenBuilder t : tb) if (t.size() > 100) t.add(DOTS);

      // draw row contents
      byte[] focusStr = null;
      int fx = -1;
      double x = 1;
      for (int c = 0; c < nCols; ++c) {
        // draw single column
        final double cw = w * tdata.cols[c].width;
        final double ce = x + cw;

        if (ce != 0) {
          final byte[] str = tb[c].size() != 0 ? tb[c].finish() : null;
          if (str != null) {
            if (tdata.mouseX > x && tdata.mouseX < ce || fcol == c) {
              fx = (int) x;
              focusStr = str;
            }
            BaseXLayout.chopString(g, str, (int) x + 1, posY + 2, (int) cw - 4, fsz);
            tb[c].reset();
          }
        }
        x = ce;
      }

      // highlight focused entry
      if (rf || fcol != -1) {
        if (focusStr != null) {
          final int sw = BaseXLayout.width(g, focusStr) + 8;
          if (fx > w - sw - 2) fx = w - sw - 2;
          g.setColor(GUIConstants.color(col + 2));
          g.fillRect(fx - 2, posY, sw, rowH - 1);
          g.setColor(Color.black);
          BaseXLayout.chopString(g, focusStr, fx + 1, posY + 2, sw, fsz);

          // cache focused string
          focusedString = string(focusStr);
          final int i = focusedString.indexOf("; ");
          if (i != -1) focusedString = focusedString.substring(0, i);
        }
      }
    }
    gui.painting = false;
  }
Exemple #26
0
  @Override
  void drawRectangles(final Graphics g, final MapRects rects, final float scale) {
    // some additions to set up borders
    final MapRect l = view.layout.layout;
    l.x = (int) scale * l.x;
    l.y = (int) scale * l.y;
    l.w = (int) scale * l.w;
    l.h = (int) scale * l.h;
    final int ww = view.getWidth();
    final int hh = view.getWidth();

    final Data data = view.gui.context.data();
    final int fsz = GUIConstants.fontSize;

    final int off = gopts.get(GUIOptions.MAPOFFSETS);
    final int rs = rects.size;
    for (int ri = 0; ri < rs; ++ri) {
      // get rectangle information
      final MapRect r = rects.get(ri);
      final int pre = r.pre;

      // level 1: next context node, set marker pointer to 0
      final int lvl = r.level;

      final boolean full = r.w == ww && r.h == hh;
      Color col = color(rects, ri);
      final boolean mark = col != null;

      r.pos =
          view.gui.context.marked.ftpos != null
              ? view.gui.context.marked.ftpos.get(data, pre)
              : null;
      g.setColor(mark ? col : GUIConstants.color(lvl));

      if (r.w < l.x + l.w || r.h < l.y + l.h || off < 2 || ViewData.leaf(gopts, data, pre)) {
        g.fillRect(r.x, r.y, r.w, r.h);
      } else {
        // painting only border for non-leaf nodes..
        g.fillRect(r.x, r.y, l.x, r.h);
        g.fillRect(r.x, r.y, r.w, l.y);
        g.fillRect(r.x + r.w - l.w, r.y, l.w, r.h);
        g.fillRect(r.x, r.y + r.h - l.h, r.w, l.h);
      }

      if (!full) {
        col = mark ? GUIConstants.colormark3 : GUIConstants.color(lvl + 2);
        g.setColor(col);
        g.drawRect(r.x, r.y, r.w, r.h);
        col = mark ? GUIConstants.colormark4 : GUIConstants.color(Math.max(0, lvl - 2));
        g.setColor(col);
        g.drawLine(r.x + r.w, r.y, r.x + r.w, r.y + r.h);
        g.drawLine(r.x, r.y + r.h, r.x + r.w, r.y + r.h);
      }

      // skip drawing of string if there is no space
      if (r.w <= 3 || r.h < GUIConstants.fontSize) continue;

      r.x += 3;
      r.w -= 3;

      final int kind = data.kind(pre);
      if (kind == Data.ELEM || kind == Data.DOC) {
        g.setColor(Color.black);
        g.setFont(GUIConstants.font);
        BaseXLayout.chopString(g, ViewData.name(gopts, data, pre), r.x, r.y, r.w, fsz);
      } else {
        g.setColor(GUIConstants.color(r.level * 2 + 8));
        g.setFont(GUIConstants.mfont);
        final byte[] text = ViewData.content(data, pre, false);

        r.thumb = MapRenderer.calcHeight(g, r, text, fsz) >= r.h;
        if (r.thumb) {
          MapRenderer.drawThumbnails(g, r, text, fsz);
        } else {
          MapRenderer.drawText(g, r, text, fsz);
        }
      }
      r.x -= 3;
      r.w += 3;
    }
  }
Exemple #27
0
 /**
  * Adds the project icon to the dock.
  *
  * @throws Exception if any error occurs.
  */
 private void addDockIcon() throws Exception {
   invoke("setDockIconImage", Image.class, BaseXLayout.image("logo"));
 }
Exemple #28
0
 /**
  * Constructor.
  *
  * @param s small icon
  * @param l large icon
  */
 Msg(final String s, final String l) {
   small = BaseXLayout.icon(s);
   large = UIManager.getIcon("OptionPane." + l + "Icon");
 }
Exemple #29
0
 /**
  * Default constructor.
  *
  * @param win parent window
  */
 public BaseXTabs(final Window win) {
   super();
   BaseXLayout.addInteraction(this, win);
 }