[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 |
|
---|
| 79 | @Override
|
---|
| 80 | public void setAnnotation(boolean val) {
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | @Override
|
---|
| 85 | public int getHeight() {
|
---|
| 86 | return HEIGHT;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | @Override
|
---|
[489] | 90 | public Integer getWidth() {
|
---|
[333] | 91 | return WIDTH;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | @Override
|
---|
[1102] | 95 | public Bounds updateBounds()
|
---|
| 96 | {
|
---|
| 97 | return new AxisAlignedBoxBounds((int) _x, (int) _y, WIDTH, HEIGHT);
|
---|
[333] | 98 | }
|
---|
| 99 |
|
---|
| 100 | @Override
|
---|
| 101 | public void onParentStateChanged(ItemParentStateChangedEvent e) {
|
---|
| 102 | super.onParentStateChanged(e);
|
---|
| 103 |
|
---|
| 104 | switch (e.getEventType()) {
|
---|
| 105 |
|
---|
| 106 | case ItemParentStateChangedEvent.EVENT_TYPE_ADDED:
|
---|
| 107 | case ItemParentStateChangedEvent.EVENT_TYPE_ADDED_VIA_OVERLAY:
|
---|
| 108 | case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN:
|
---|
| 109 | case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN_VIA_OVERLAY:
|
---|
| 110 | // TODO: Invoke later for concurrent modification possibility?
|
---|
| 111 | selfDestruct();
|
---|
| 112 | break;
|
---|
| 113 |
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | private void selfDestruct() {
|
---|
| 118 |
|
---|
| 119 | Frame parent = getParent();
|
---|
| 120 | parent.removeItem(this);
|
---|
| 121 |
|
---|
[1102] | 122 | Frame currentFrame = DisplayController.getCurrentFrame();
|
---|
[333] | 123 |
|
---|
| 124 | if (currentFrame != null) {
|
---|
| 125 |
|
---|
| 126 | Text source = new Text(currentFrame.getNextItemID());
|
---|
| 127 | source.setParent(currentFrame);
|
---|
| 128 | SampleRecorder destructableRecorder = new SampleRecorder(source, null, true);
|
---|
| 129 | destructableRecorder.setCountdown(countdown);
|
---|
| 130 | destructableRecorder.setPosition((int)_x, (int)_y);
|
---|
| 131 | currentFrame.addAllItems(destructableRecorder.getItems());
|
---|
| 132 | destructableRecorder.commenceOverdubRecording();
|
---|
| 133 |
|
---|
| 134 |
|
---|
| 135 | }
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | }
|
---|