Search in sources :

Example 76 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 77 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 78 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 79 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)

Example 80 with Rectangle

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

the class AnimationStripPanel method mousePressed.

public void mousePressed(MouseEvent evt) {
    Point p = evt.getPoint();
    controller.stripIndexSelected(-1);
    boolean selectedSlot = false;
    for (int i = 0; i < slotList.size(); ++i) {
        Slot slot = slotList.get(i);
        slot.setSelected(false);
        Rectangle rect = slot.getRect();
        if (MathUtil.pointRectCollide(p, rect)) {
            slot.setSelected(true);
            controller.stripIndexSelected(i);
            //slot.setDragged(true);
            controller.setWorkingCell(slot.getCell());
            selectedSlot = true;
        }
    }
    if (!selectedSlot)
        controller.setWorkingCell(null);
    repaint();
}
Also used : Rectangle(java.awt.Rectangle) Point(java.awt.Point) Point(java.awt.Point)

Aggregations

Rectangle (java.awt.Rectangle)809 Point (java.awt.Point)201 Dimension (java.awt.Dimension)81 BufferedImage (java.awt.image.BufferedImage)68 Graphics2D (java.awt.Graphics2D)65 Color (java.awt.Color)48 Insets (java.awt.Insets)47 ArrayList (java.util.ArrayList)37 Font (java.awt.Font)29 Test (org.junit.Test)28 IOException (java.io.IOException)27 GraphicsConfiguration (java.awt.GraphicsConfiguration)23 Paint (java.awt.Paint)23 GradientPaint (java.awt.GradientPaint)22 FontMetrics (java.awt.FontMetrics)21 Graphics (java.awt.Graphics)21 Rectangle2D (java.awt.geom.Rectangle2D)21 Robot (java.awt.Robot)19 File (java.io.File)19 PeakResult (gdsc.smlm.results.PeakResult)18