void showResults() {
   int count = rt.getCounter();
   // if (count==0) return;
   boolean lastSlice = !processStack || slice == imp.getStackSize();
   if ((showChoice == OVERLAY_OUTLINES || showChoice == OVERLAY_MASKS) && slice == 1 && count > 0)
     imp.setOverlay(overlay);
   else if (outlines != null && lastSlice) {
     String title = imp != null ? imp.getTitle() : "Outlines";
     String prefix;
     if (showChoice == MASKS) prefix = "Mask of ";
     else if (showChoice == ROI_MASKS) prefix = "Count Masks of ";
     else prefix = "Drawing of ";
     outlines.update(drawIP);
     outputImage = new ImagePlus(prefix + title, outlines);
     if (inSituShow) {
       if (imp.getStackSize() == 1) Undo.setup(Undo.TRANSFORM, imp);
       imp.setStack(null, outputImage.getStack());
     } else if (!hideOutputImage) outputImage.show();
   }
   if (showResults && !processStack) {
     TextPanel tp = IJ.getTextPanel();
     if (beginningCount > 0 && tp != null && tp.getLineCount() != count) rt.show("Results");
     Analyzer.firstParticle = beginningCount;
     Analyzer.lastParticle = Analyzer.getCounter() - 1;
   } else Analyzer.firstParticle = Analyzer.lastParticle = 0;
 }
Пример #2
0
 @Test
 public void preferredSize() throws Exception {
   useFrame();
   panel.doLayout();
   assertEquals(58, panel.getWidth());
   assertEquals(14, panel.getHeight());
 }
Пример #3
0
  @Test
  public void observerAddedForLineStyling() throws Exception {
    panel.setText("some text", parent);
    panel.buildLines();

    Style style = panel.getTextChunks().get(0).getStyle();
    assertEquals(true, style.hasObserver(panel));
  }
Пример #4
0
 @Test
 public void preferredSizeWithBigFontSize() throws Exception {
   useFrame();
   style.setFontSize("40");
   panel.doLayout();
   assertEquals(80, panel.getWidth());
   assertEquals(138, panel.getHeight());
 }
Пример #5
0
 @Test
 public void dimensionsWhenLastLineIsLongest() throws Exception {
   useFrame();
   panel.setText("1\n2\n3\nlongest", parent);
   panel.doLayout();
   assertEquals(true, panel.getWidth() >= 39 && panel.getWidth() <= 41);
   assertEquals(55, panel.getHeight());
 }
Пример #6
0
  @Test
  public void layoutCausesDirtyRegion() throws Exception {
    panel.doLayout();

    ArrayList<Rectangle> list = new ArrayList<Rectangle>();
    root.getAndClearDirtyRegions(list);
    assertEquals(1, list.size());
    assertEquals(panel.getAbsoluteBounds(), list.get(0));
  }
Пример #7
0
  @Test
  public void parentSizeChangesAlwaysRequiresLayout() throws Exception {
    panel.resetLayout();
    assertEquals(false, panel.needsLayout());

    panel.consumableAreaChanged();

    assertEquals(true, panel.needsLayout());
  }
Пример #8
0
 @Test
 public void preferredSizeWithMoreText() throws Exception {
   useFrame();
   panel.setText(
       "Once upon a time, there was a developer working on a tool called Limelight.", parent);
   panel.doLayout();
   assertEquals(true, panel.getWidth() >= 97 && panel.getWidth() <= 99);
   assertEquals(69, panel.getHeight());
 }
Пример #9
0
  @Test
  public void textChunksOverwrittenOnCompile() throws Exception {
    panel.setText("Here is some original text.", parent);
    panel.buildLines();

    int originalChunks = panel.getTextChunks().size();

    panel.buildLines();

    assertEquals(originalChunks, panel.getTextChunks().size());
  }
Пример #10
0
  @Test
  public void changingTestRequiresUpdates() throws Exception {
    parent.doLayout();
    assertEquals(false, panel.needsLayout());
    assertEquals(false, parent.needsLayout());

    panel.setText("New Text", parent);

    assertEquals(true, panel.needsLayout());
    assertEquals(true, parent.needsLayout());
  }
Пример #11
0
  @Test
  public void teardownStyledTextBeforeDiscarding() throws Exception {
    panel.setText("Original Text", parent);
    panel.doLayout();
    List<StyleObserver> observers = panel.getStyle().getObservers();
    assertEquals(1, observers.size());
    StyleObserver observer = observers.get(0);

    panel.doLayout();
    List<StyleObserver> newObservers = panel.getStyle().getObservers();
    assertEquals(1, newObservers.size());
    StyleObserver newObserver = newObservers.get(0);
    assertNotSame(newObserver, observer);
  }
Пример #12
0
  @Test
  public void buildingLines() throws Exception {
    panel.setText("some text", parent);
    panel.buildLines();

    List<TextLayout> lines = panel.getLines();

    assertEquals(1, lines.size());
    TextLayout layout = lines.get(0);
    assertEquals(9, layout.getCharacterCount());
    assertSubString("family=" + defaultFontFace, layout.toString());
    assertSubString("name=" + defaultFontFace, layout.toString());
    assertSubString("size=" + defaultFontSize, layout.toString());
  }
Пример #13
0
  @Test
  public void textColor() throws Exception {
    createStyles();
    panel.setText("text <my_other_style>here</my_other_style> man", parent);
    panel.buildLines();

    StyledText first = panel.getTextChunks().get(0);
    assertEquals(defaultTextColor, first.getColor());

    StyledText second = panel.getTextChunks().get(1);
    assertEquals(new Color(0x0000FF), second.getColor());

    StyledText third = panel.getTextChunks().get(2);
    assertEquals(defaultTextColor, third.getColor());
  }
Пример #14
0
  @Test
  public void unrecognizedInterlacedStyle() {
    createStyles();
    parent.setSize(200, 100);
    panel.setText(
        "This is <my_other_style>some </my_other_style><bogus_style>fantastic</bogus_style><my_style>text</my_style>",
        parent);
    panel.buildLines();

    List<StyledText> chunks = panel.getTextChunks();
    assertEquals(4, chunks.size());

    StyledText interlacedLayout = chunks.get(2);
    assertNoSubString("name=Cuneiform", interlacedLayout.toString());
    assertNoSubString("size=19", interlacedLayout.toString());
  }
Пример #15
0
  public EncodingPanel(@NotNull final Project project) {
    super(project);
    update = new Alarm(this);
    myComponent =
        new TextPanel.ExtraSize() {
          @Override
          protected void paintComponent(@NotNull final Graphics g) {
            super.paintComponent(g);
            if (actionEnabled && getText() != null) {
              final Rectangle r = getBounds();
              final Insets insets = getInsets();
              Icon arrows = AllIcons.Ide.Statusbar_arrows;
              arrows.paintIcon(
                  this,
                  g,
                  r.width - insets.right - arrows.getIconWidth() - 2,
                  r.height / 2 - arrows.getIconHeight() / 2);
            }
          }
        };

    new ClickListener() {
      @Override
      public boolean onClick(@NotNull MouseEvent e, int clickCount) {
        update();
        showPopup(e);
        return true;
      }
    }.installOn(myComponent);
    myComponent.setBorder(WidgetBorder.WIDE);
  }
Пример #16
0
  /** Saves the displayed text. */
  private void save() {
    final BaseXFileChooser fc =
        new BaseXFileChooser(SAVE_AS, gui.gopts.get(GUIOptions.WORKPATH), gui).suffix(IO.XMLSUFFIX);

    final IO file = fc.select(Mode.FSAVE);
    if (file == null) return;
    gui.gopts.set(GUIOptions.WORKPATH, file.path());

    gui.cursor(CURSORWAIT, true);
    final MainOptions opts = gui.context.options;
    final int mh = opts.get(MainOptions.MAXHITS);
    opts.set(MainOptions.MAXHITS, -1);
    opts.set(MainOptions.CACHEQUERY, false);

    try (final PrintOutput out = new PrintOutput(file.toString())) {
      if (cmd != null) {
        cmd.execute(gui.context, out);
      } else if (ns != null) {
        ns.serialize(Serializer.get(out));
      } else {
        final byte[] txt = text.getText();
        for (final byte t : txt) if (t < 0 || t > ' ' || ws(t)) out.write(t);
      }
    } catch (final IOException ex) {
      BaseXDialog.error(gui, Util.info(FILE_NOT_SAVED_X, file));
    } finally {
      opts.set(MainOptions.MAXHITS, mh);
      opts.set(MainOptions.CACHEQUERY, true);
      gui.cursor(CURSORARROW, true);
    }
  }
Пример #17
0
  @Test
  public void textChanged() throws Exception {
    assertEquals(false, panel.textChanged());

    panel.setText("Something", parent);
    assertEquals(true, panel.needsLayout());

    panel.resetLayout();
    panel.setText("Something", parent);
    assertEquals(false, panel.needsLayout());

    panel.setText("Something Else", parent);
    assertEquals(true, panel.needsLayout());

    panel.resetLayout();
    assertEquals(false, panel.needsLayout());
  }
Пример #18
0
  @Test
  public void stylingAppliedToLine() throws Exception {
    createStyles();

    parent.setSize(200, 100);
    panel.setText("<my_style>some text</my_style>", parent);
    panel.buildLines();

    List<TextLayout> lines = panel.getLines();

    TextLayout layout = lines.get(0);
    assertEquals(1, lines.size());
    assertEquals(9, layout.getCharacterCount());
    assertSubString("family=Helvetica", layout.toString());
    assertSubString("name=Helvetica", layout.toString());
    assertSubString("style=bold", layout.toString());
    assertSubString("size=20", layout.toString());
  }
Пример #19
0
  @Test
  public void styledTextOnSameLine() {
    createStyles();
    parent.setSize(200, 100);
    panel.setText("This <my_other_style>some </my_other_style> text", parent);
    panel.buildLines();

    List<TextLayout> lines = panel.getLines();
    assertEquals(1, lines.size());

    String onlyLine = lines.get(0).toString();
    assertSubString("name=Cuneiform", onlyLine);
    assertSubString("size=19", onlyLine);
    assertSubString("style=italic", onlyLine);
    assertSubString("name=" + defaultFontFace, onlyLine);
    assertSubString("size=" + defaultFontSize, onlyLine);
    assertSubString("style=" + defaultFontStyle, onlyLine);
  }
Пример #20
0
  @Test
  public void styledInheritsFromDefault() {
    createStyles();
    parent.setSize(200, 100);
    panel.setText("<size_only_style>This some text</size_only_style>", parent);
    panel.buildLines();

    List<TextLayout> lines = panel.getLines();
    assertEquals(1, lines.size());

    String onlyLine = lines.get(0).toString();
    assertSubString("name=" + defaultFontFace, onlyLine);
    assertSubString("size=" + "25", onlyLine);
    assertSubString("style=" + defaultFontStyle, onlyLine);

    StyledText first = panel.getTextChunks().get(0);
    assertEquals(defaultTextColor, first.getColor());
  }
Пример #21
0
  @Test
  public void styledAcrossLineBreak() {
    createStyles();
    parent.setSize(200, 100);
    panel.setText("This <my_other_style>some\n more</my_other_style> text", parent);

    panel.buildLines();

    List<TextLayout> lines = panel.getLines();
    assertEquals(2, lines.size());

    TextLayout first = lines.get(0);
    TextLayout second = lines.get(1);
    assertSubString("name=Cuneiform", first.toString());
    assertSubString("name=" + defaultFontFace, first.toString());
    assertSubString("name=Cuneiform", second.toString());
    assertSubString("name=" + defaultFontFace, second.toString());
  }
Пример #22
0
 /**
  * Sets the output text.
  *
  * @param out cached output
  */
 public void setText(final ArrayOutput out) {
   final byte[] buf = out.buffer();
   final int size = (int) out.size();
   final byte[] chop = token(DOTS);
   if (out.finished() && size >= chop.length) {
     System.arraycopy(chop, 0, buf, size - chop.length, chop.length);
   }
   text.setText(buf, size);
   header.setText((out.finished() ? CHOPPED : "") + RESULT);
   home.setEnabled(gui.context.data() != null);
 }
Пример #23
0
  @Test
  public void multipleStylesAppliedToLine() throws Exception {
    createStyles();

    parent.setSize(200, 100);
    panel.setText("<my_style>some </my_style><my_other_style>text</my_other_style>", parent);
    panel.buildLines();

    List<StyledText> chunks = panel.getTextChunks();

    StyledText layout = chunks.get(0);
    assertEquals(5, layout.getText().length());
    assertSubString("family=Helvetica", layout.toString());
    assertSubString("name=Helvetica", layout.toString());
    assertSubString("style=bold", layout.toString());
    assertSubString("size=20", layout.toString());

    StyledText layout2 = chunks.get(1);
    assertEquals(5, layout.getText().length());
    assertSubString("family=Dialog", layout2.toString());
    assertSubString("name=Cuneiform", layout2.toString());
    assertSubString("style=italic", layout2.toString());
    assertSubString("size=19", layout2.toString());
  }
Пример #24
0
  @Test
  public void layoutFlushedChangedText() throws Exception {
    panel.resetLayout();
    assertEquals(false, panel.needsLayout());

    panel.setText("Something", parent);
    assertEquals(true, panel.needsLayout());

    panel.doLayout();
    assertEquals(false, panel.needsLayout());
  }
Пример #25
0
  @Test
  public void resizesTextWhenSizeChanges() throws Exception {
    panel.setText(
        "Some really long text so that there are multiple lines requiring layout when the size changes.",
        parent);
    panel.doLayout();

    int originalHeight = panel.getHeight();
    parent.setSize(400, 200);
    panel.doLayout();

    int newHeight = panel.getHeight();

    assertEquals(true, 200 - panel.getWidth() < 100);
    assertEquals(true, newHeight < originalHeight);
  }
Пример #26
0
  /**
   * Default constructor.
   *
   * @param man view manager
   */
  public TextView(final ViewNotifier man) {
    super(TEXTVIEW, man);
    border(5).layout(new BorderLayout(0, 5));

    header = new BaseXHeader(RESULT);

    home = BaseXButton.command(GUIMenuCmd.C_HOME, gui);
    home.setEnabled(false);

    text = new TextPanel(false, gui);
    text.setSyntax(new SyntaxXML());
    search = new SearchEditor(gui, text);

    final AbstractButton save = BaseXButton.get("c_save", SAVE, false, gui);
    final AbstractButton find = search.button(FIND);

    final BaseXBack buttons = new BaseXBack(false);
    buttons.layout(new TableLayout(1, 3, 1, 0)).border(0, 0, 4, 0);
    buttons.add(save);
    buttons.add(home);
    buttons.add(find);

    final BaseXBack b = new BaseXBack(false).layout(new BorderLayout());
    b.add(buttons, BorderLayout.WEST);
    b.add(header, BorderLayout.EAST);
    add(b, BorderLayout.NORTH);

    add(search, BorderLayout.CENTER);

    save.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            save();
          }
        });
    refreshLayout();
  }
Пример #27
0
 @Override
 public void refreshLayout() {
   header.refreshLayout();
   text.setFont(mfont);
   search.bar().refreshLayout();
 }
Пример #28
0
 @Test
 public void canBeBuffered() throws Exception {
   assertEquals(false, panel.canBeBuffered());
 }
Пример #29
0
 @Test
 public void testConstructor() throws Exception {
   assertEquals(parent, panel.getPanel());
   assertEquals("Some Text", panel.getText());
 }
Пример #30
0
 private void useFrame() {
   frame = new Frame();
   frame.setVisible(true);
   panel.setGraphics(frame.getGraphics());
 }