Search in sources :

Example 1 with Rectangle

use of java.awt.Rectangle in project WordCram by danbernier.

the class AWordCramEngine method willSkipWordsWhoseShapesAreTooSmallEvenWhenMinShapeSizeIsZero.

@Test
public void willSkipWordsWhoseShapesAreTooSmallEvenWhenMinShapeSizeIsZero() {
    Word big = new Word("big", 10);
    Word small = new Word("small", 1);
    Shape bigShape = new Rectangle(0, 0, 20, 20);
    Shape smallShape = new Rectangle(0, 0, 0, 1);
    renderOptions.minShapeSize = 0;
    when(shaper.getShapeFor(eq(big.word), any(PFont.class), anyFloat(), anyFloat())).thenReturn(bigShape);
    when(shaper.getShapeFor(eq(small.word), any(PFont.class), anyFloat(), anyFloat())).thenReturn(smallShape);
    WordCramEngine engine = getEngine(big, small);
    Word[] skippedWords = engine.getSkippedWords();
    Assert.assertEquals(1, skippedWords.length);
    Assert.assertSame(small, skippedWords[0]);
    Assert.assertEquals(WordSkipReason.SHAPE_WAS_TOO_SMALL, small.wasSkippedBecause());
    Assert.assertNull(big.wasSkippedBecause());
}
Also used : Shape(java.awt.Shape) PFont(processing.core.PFont) Rectangle(java.awt.Rectangle) Test(org.junit.Test)

Example 2 with Rectangle

use of java.awt.Rectangle in project WordCram by danbernier.

the class AWordCramEngine method willSkipWordsWhoseShapesAreTooSmall.

@Test
public void willSkipWordsWhoseShapesAreTooSmall() {
    Word big = new Word("big", 10);
    Word small = new Word("small", 1);
    Shape bigShape = new Rectangle(0, 0, 20, 20);
    Shape smallShape = new Rectangle(0, 0, 1, 1);
    when(shaper.getShapeFor(eq(big.word), any(PFont.class), anyFloat(), anyFloat())).thenReturn(bigShape);
    when(shaper.getShapeFor(eq(small.word), any(PFont.class), anyFloat(), anyFloat())).thenReturn(smallShape);
    WordCramEngine engine = getEngine(big, small);
    Word[] skippedWords = engine.getSkippedWords();
    Assert.assertEquals(1, skippedWords.length);
    Assert.assertSame(small, skippedWords[0]);
    Assert.assertEquals(WordSkipReason.SHAPE_WAS_TOO_SMALL, small.wasSkippedBecause());
    Assert.assertNull(big.wasSkippedBecause());
}
Also used : Shape(java.awt.Shape) PFont(processing.core.PFont) Rectangle(java.awt.Rectangle) Test(org.junit.Test)

Example 3 with Rectangle

use of java.awt.Rectangle in project WordCram by danbernier.

the class AnEngineWord method willSetItselfOnItsWord.

@Test
public void willSetItselfOnItsWord() {
    Word aWord = new Word("hello", 42.0f);
    EngineWord engineWord = new EngineWord(aWord, 1, 1000, new BBTreeBuilder());
    // To verify that it hooked up to the Word, set EWord's shape, and get it from Word.
    int anySwelling = 0;
    int width = 939;
    int height = 42;
    engineWord.setShape(new Rectangle(0, 0, width, height), anySwelling);
    double zeroDelta = 0.0;
    Assert.assertEquals(width, aWord.getRenderedWidth(), zeroDelta);
    Assert.assertEquals(height, aWord.getRenderedHeight(), zeroDelta);
}
Also used : Rectangle(java.awt.Rectangle) Test(org.junit.Test)

Example 4 with Rectangle

use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.

the class AnimationStripPanel method getStripSize.

private Dimension getStripSize() {
    Dimension ret = new Dimension(0, 0);
    for (int i = 0; i < slotList.size(); ++i) {
        Rectangle slotRect = slotList.get(i).getRect();
        int bottom = slotRect.y + slotRect.height;
        int right = slotRect.x + slotRect.width;
        if (bottom > ret.height)
            ret.height = bottom;
        if (right > ret.width)
            ret.width = right;
    }
    return ret;
}
Also used : Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) Point(java.awt.Point)

Example 5 with Rectangle

use of java.awt.Rectangle in project darkFunction-Editor by darkFunction.

the class AnimationStripPanel method addCell.

private void addCell(AnimationCell aCell) {
    Point p = new Point(0, 0);
    if (slotList.size() > 0) {
        Rectangle lastSlotRect = slotList.get(slotList.size() - 1).getRect();
        p.x = lastSlotRect.x + lastSlotRect.width;
    }
    Slot slot = new Slot(aCell, p, 86);
    slotList.add(slot);
    for (int i = 0; i < slotList.size(); ++i) slotList.get(i).setSelected(false);
    slot.setSelected(true);
    // stretch and update scrollbar
    Dimension stripSize = getStripSize();
    this.setPreferredSize(stripSize);
    this.setSize(stripSize);
    animation.setCurrentCellIndex(slotList.size() - 1);
    if (controller != null) {
        controller.setWorkingCell(aCell);
        controller.stripIndexSelected(slotList.size() - 1);
    }
    repaint();
}
Also used : Rectangle(java.awt.Rectangle) Point(java.awt.Point) Dimension(java.awt.Dimension) Point(java.awt.Point)

Aggregations

Rectangle (java.awt.Rectangle)654 Point (java.awt.Point)147 BufferedImage (java.awt.image.BufferedImage)61 Dimension (java.awt.Dimension)49 Graphics2D (java.awt.Graphics2D)48 Insets (java.awt.Insets)36 Color (java.awt.Color)31 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)28 GraphicsConfiguration (java.awt.GraphicsConfiguration)21 IOException (java.io.IOException)21 Robot (java.awt.Robot)19 PeakResult (gdsc.smlm.results.PeakResult)18 File (java.io.File)18 Font (java.awt.Font)17 FontMetrics (java.awt.FontMetrics)17 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)16 SampleModel (java.awt.image.SampleModel)15 Component (java.awt.Component)14 ImagePlus (ij.ImagePlus)13