[333] | 1 | package org.apollo.items;
|
---|
| 2 |
|
---|
| 3 | import org.apollo.ApolloSystem;
|
---|
[355] | 4 | import org.apollo.gui.Strokes;
|
---|
[333] | 5 | import org.apollo.io.IconRepository;
|
---|
| 6 | import org.apollo.widgets.SampleRecorder;
|
---|
[1102] | 7 | import org.expeditee.core.Colour;
|
---|
| 8 | import org.expeditee.core.Dimension;
|
---|
| 9 | import org.expeditee.core.Fill;
|
---|
| 10 | import org.expeditee.core.GradientFill;
|
---|
| 11 | import org.expeditee.core.Point;
|
---|
| 12 | import org.expeditee.core.Stroke;
|
---|
| 13 | import org.expeditee.core.bounds.AxisAlignedBoxBounds;
|
---|
| 14 | import org.expeditee.core.bounds.Bounds;
|
---|
| 15 | import org.expeditee.gio.EcosystemManager;
|
---|
| 16 | import org.expeditee.gio.GraphicsManager;
|
---|
[333] | 17 | import org.expeditee.gui.Browser;
|
---|
[1102] | 18 | import org.expeditee.gui.DisplayController;
|
---|
[333] | 19 | import org.expeditee.gui.Frame;
|
---|
| 20 | import org.expeditee.items.Item;
|
---|
| 21 | import org.expeditee.items.ItemParentStateChangedEvent;
|
---|
| 22 | import org.expeditee.items.Text;
|
---|
| 23 |
|
---|
| 24 | public class RecordOverdubLauncher extends Item {
|
---|
| 25 |
|
---|
| 26 | private static int WIDTH = 80;
|
---|
| 27 | private static int HEIGHT = 80;
|
---|
[1102] | 28 | private static Stroke BORDER_STROKE = Strokes.SOLID_1;
|
---|
[333] | 29 | private int countdown;
|
---|
| 30 |
|
---|
[1102] | 31 | private static final Colour BASE_COLOR = Colour.FromRGB255(255, 100, 100);
|
---|
| 32 | private static final Colour HIGHLIGHT_COLOR = Colour.FromRGB255(253, 255, 201);
|
---|
[333] | 33 |
|
---|
| 34 | public RecordOverdubLauncher(int countdown) {
|
---|
| 35 | this.setID(getParentOrCurrentFrame().getNextItemID());
|
---|
| 36 | this.countdown = countdown;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | @Override
|
---|
| 40 | public Item copy() {
|
---|
[363] | 41 | RecordOverdubLauncher copy = new RecordOverdubLauncher(countdown);
|
---|
[333] | 42 |
|
---|
| 43 | DuplicateItem(this, copy);
|
---|
| 44 |
|
---|
| 45 | return copy;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | @Override
|
---|
| 49 | public Item merge(Item merger, int mouseX, int mouseY) {
|
---|
| 50 | return null;
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | @Override
|
---|
[1102] | 54 | public void paint() {
|
---|
[333] | 55 | if (Browser._theBrowser == null) return;
|
---|
| 56 |
|
---|
[1102] | 57 | GraphicsManager g = EcosystemManager.getGraphicsManager();
|
---|
[333] | 58 |
|
---|
[1102] | 59 | Fill fill = null;
|
---|
[333] | 60 | if (ApolloSystem.useQualityGraphics) {
|
---|
[1102] | 61 | Point fromPoint = new Point(_x + (WIDTH / 2), _y);
|
---|
| 62 | Point toPoint = new Point(_x + (WIDTH / 2), _y + HEIGHT - (HEIGHT / 5));
|
---|
| 63 | fill = new GradientFill(HIGHLIGHT_COLOR, fromPoint, BASE_COLOR, toPoint);
|
---|
[333] | 64 | } else {
|
---|
[1102] | 65 | fill = new Fill(BASE_COLOR);
|
---|
[333] | 66 | }
|
---|
| 67 |
|
---|
[1102] | 68 | Point topLeft = new Point((int)_x, (int)_y);
|
---|
| 69 | Dimension size = new Dimension(WIDTH, HEIGHT);
|
---|
| 70 | g.drawRectangle(topLeft, size, 0.0, fill, Colour.BLACK, BORDER_STROKE, null);
|
---|
[333] | 71 |
|
---|
[1102] | 72 | /*IconRepository.getIcon("recordplay.png").paintIcon(
|
---|
| 73 | Browser._theBrowser.getContentPane(), g, getX() + 25, getY() + 25);*/
|
---|
[333] | 74 |
|
---|
[1102] | 75 | g.drawImage(IconRepository.getIcon("recordplay.png"), new Point(getX() + 25, getY() + 25));
|
---|
[333] | 76 | }
|
---|
| 77 |
|
---|
| 78 | @Override
|
---|
| 79 | public void setAnnotation(boolean val) {
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | @Override
|
---|
| 84 | public int getHeight() {
|
---|
| 85 | return HEIGHT;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | @Override
|
---|
[489] | 89 | public Integer getWidth() {
|
---|
[333] | 90 | return WIDTH;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | @Override
|
---|
[1102] | 94 | public Bounds updateBounds()
|
---|
| 95 | {
|
---|
| 96 | return new AxisAlignedBoxBounds((int) _x, (int) _y, WIDTH, HEIGHT);
|
---|
[333] | 97 | }
|
---|
| 98 |
|
---|
| 99 | @Override
|
---|
| 100 | public void onParentStateChanged(ItemParentStateChangedEvent e) {
|
---|
| 101 | super.onParentStateChanged(e);
|
---|
| 102 |
|
---|
| 103 | switch (e.getEventType()) {
|
---|
| 104 |
|
---|
| 105 | case ItemParentStateChangedEvent.EVENT_TYPE_ADDED:
|
---|
| 106 | case ItemParentStateChangedEvent.EVENT_TYPE_ADDED_VIA_OVERLAY:
|
---|
| 107 | case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN:
|
---|
| 108 | case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN_VIA_OVERLAY:
|
---|
| 109 | // TODO: Invoke later for concurrent modification possibility?
|
---|
| 110 | selfDestruct();
|
---|
| 111 | break;
|
---|
| 112 |
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | private void selfDestruct() {
|
---|
| 117 |
|
---|
| 118 | Frame parent = getParent();
|
---|
| 119 | parent.removeItem(this);
|
---|
| 120 |
|
---|
[1102] | 121 | Frame currentFrame = DisplayController.getCurrentFrame();
|
---|
[333] | 122 |
|
---|
| 123 | if (currentFrame != null) {
|
---|
| 124 |
|
---|
| 125 | Text source = new Text(currentFrame.getNextItemID());
|
---|
| 126 | source.setParent(currentFrame);
|
---|
| 127 | SampleRecorder destructableRecorder = new SampleRecorder(source, null, true);
|
---|
| 128 | destructableRecorder.setCountdown(countdown);
|
---|
| 129 | destructableRecorder.setPosition((int)_x, (int)_y);
|
---|
| 130 | currentFrame.addAllItems(destructableRecorder.getItems());
|
---|
| 131 | destructableRecorder.commenceOverdubRecording();
|
---|
| 132 |
|
---|
| 133 |
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | }
|
---|