Changeset 1102 for trunk/src/org/apollo/widgets/SampleRecorder.java
- Timestamp:
- 05/10/18 16:04:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/widgets/SampleRecorder.java
r1057 r1102 1 1 package org.apollo.widgets; 2 2 3 import java.awt.Color;4 3 import java.awt.Dimension; 5 4 import java.awt.FontMetrics; … … 49 48 import org.apollo.util.ApolloSystemLog; 50 49 import org.apollo.util.TrackNameCreator; 51 import org.expeditee.gui.DisplayIO; 50 import org.expeditee.core.Colour; 51 import org.expeditee.gio.gesture.StandardGestureActions; 52 import org.expeditee.gio.swing.SwingConversions; 53 import org.expeditee.gio.swing.SwingMiscManager; 54 import org.expeditee.gui.DisplayController; 52 55 import org.expeditee.gui.Frame; 53 import org.expeditee.gui.FrameGraphics;54 import org.expeditee.gui.FrameMouseActions;55 56 import org.expeditee.items.ItemParentStateChangedEvent; 56 57 import org.expeditee.items.Text; 57 import org.expeditee.items.widgets. InteractiveWidget;58 import org.expeditee.items.widgets.SwingWidget; 58 59 59 60 /** … … 63 64 * 64 65 */ 65 public class SampleRecorder extends InteractiveWidget 66 implements ActionListener, Observer, MultitrackLoadListener { 66 public class SampleRecorder extends SwingWidget implements ActionListener, Observer, MultitrackLoadListener { 67 67 68 68 private enum WidgetState { … … 105 105 private final static int MAX_COUNTDOWN_TIME = 60; 106 106 107 private static final Colo r GRAPH_BACKCOLOR = Color.BLACK;108 private static final Colo r GRAPH_WAVECOLOR = Color.GREEN;107 private static final Colour GRAPH_BACKCOLOR = Colour.BLACK; 108 private static final Colour GRAPH_WAVECOLOR = Colour.GREEN; 109 109 110 110 private final static int RENDER_POINTS_PER_SECOND = 20; // how many points to render each second … … 112 112 private final static String COUNTDOWN_META = "countdown="; 113 113 114 public SampleRecorder(Text source, String[] args) { 114 public SampleRecorder(Text source, String[] args) 115 { 115 116 this(source, args, false); 116 117 } 117 118 118 public SampleRecorder(Text source, String[] args, boolean isTemporary) { 119 public SampleRecorder(Text source, String[] args, boolean isTemporary) 120 { 119 121 super(source, new JPanel(new GridBagLayout()), 120 122 AnimatedSampleGraph.GRAPH_WIDTH + (2 * HORO_SPACING), … … 132 134 // Create gui layout 133 135 recordButton = new JButton(); 134 recordButton.setIcon(IconRepository.getIcon("record.png"));136 SwingMiscManager.setJButtonIcon(recordButton, IconRepository.getIcon("record.png")); 135 137 recordButton.addActionListener(this); 136 138 recordButton.setPreferredSize(new Dimension(AnimatedSampleGraph.GRAPH_WIDTH / 2, BUTTON_HEIGHT)); 137 139 138 140 recordSynchedButton = new JButton(); 139 recordSynchedButton.setIcon(IconRepository.getIcon("recordplay.png"));141 SwingMiscManager.setJButtonIcon(recordSynchedButton, IconRepository.getIcon("recordplay.png")); 140 142 recordSynchedButton.addActionListener(this); 141 143 recordSynchedButton.setPreferredSize(new Dimension(AnimatedSampleGraph.GRAPH_WIDTH / 2, BUTTON_HEIGHT)); 142 144 143 145 stopButton = new JButton(); 144 stopButton.setIcon(IconRepository.getIcon("stop.png"));146 SwingMiscManager.setJButtonIcon(stopButton, IconRepository.getIcon("stop.png")); 145 147 stopButton.addActionListener(this); 146 148 stopButton.setPreferredSize(new Dimension(AnimatedSampleGraph.GRAPH_WIDTH, BUTTON_HEIGHT)); … … 303 305 304 306 sampleGraph.alternateText = Integer.toString(countDown); 305 sampleGraph.alternateTextColor = (countDown > 3) ? Colo r.WHITE : Color.RED;307 sampleGraph.alternateTextColor = (countDown > 3) ? Colour.WHITE : Colour.RED; 306 308 sampleGraph.invalidateGraph(); 307 FrameGraphics.refresh(true);309 DisplayController.requestRefresh(true); 308 310 309 311 countdownThread = new CountDownTimer(countDown); … … 373 375 Frame targetFrame = getParentFrame(); 374 376 if (targetFrame == null) { 375 targetFrame = Display IO.getCurrentFrame();377 targetFrame = DisplayController.getCurrentFrame(); 376 378 } 377 379 … … 398 400 } else { 399 401 400 FrameMouseActions.pickup(trackWidget.getItems());402 StandardGestureActions.pickup(trackWidget.getItems()); 401 403 402 404 // Reset the state … … 602 604 assert (state == WidgetState.Ready); 603 605 604 Frame target = Display IO.getCurrentFrame();606 Frame target = DisplayController.getCurrentFrame(); 605 607 if (target == null) return; 606 608 … … 608 610 609 611 RecordOverdubLauncher launcher = new RecordOverdubLauncher((Integer)countDownSpinner.getValue()); 610 launcher.setPosition( FrameMouseActions.MouseX, FrameMouseActions.MouseY);612 launcher.setPosition(DisplayController.getMousePosition()); 611 613 612 614 // Pick it up 613 FrameMouseActions.pickup(launcher);615 StandardGestureActions.pickup(launcher); 614 616 615 617 } … … 757 759 setState(WidgetState.LoadingPlayback, "Loading tracks..."); 758 760 759 Frame currentFrame = Display IO.getCurrentFrame();761 Frame currentFrame = DisplayController.getCurrentFrame(); 760 762 if (currentFrame == null || currentFrame.getName() == null) { 761 763 … … 843 845 844 846 private String alternateText = null; 845 private Colo r alternateTextColor = Color.WHITE;847 private Colour alternateTextColor = Colour.WHITE; 846 848 847 849 AnimatedSampleGraph() { 848 850 imageBuffer = new BufferedImage(GRAPH_WIDTH, GRAPH_HEIGHT, BufferedImage.TYPE_INT_RGB); 849 851 imageGraphics = (Graphics2D)imageBuffer.getGraphics(); 850 imageGraphics.setColor( GRAPH_BACKCOLOR);852 imageGraphics.setColor(SwingConversions.toSwingColor(GRAPH_BACKCOLOR)); 851 853 imageGraphics.fillRect(0, 0, GRAPH_WIDTH, GRAPH_HEIGHT); 852 854 setPreferredSize(new Dimension(GRAPH_WIDTH, GRAPH_HEIGHT)); … … 857 859 */ 858 860 public void clear() { 859 imageGraphics.setColor( GRAPH_BACKCOLOR);861 imageGraphics.setColor(SwingConversions.toSwingColor(GRAPH_BACKCOLOR)); 860 862 imageGraphics.fillRect(0, 0, GRAPH_WIDTH, GRAPH_HEIGHT); 861 863 invalidateGraph(); … … 867 869 if (alternateText != null) { 868 870 869 g.setColor( Color.BLACK);871 g.setColor(SwingConversions.toSwingColor(Colour.BLACK)); 870 872 g.fillRect(0, 0, getWidth(), getHeight()); 871 873 872 g.setFont( TrackWidgetCommons.FREESPACE_TRACKNAME_FONT);873 g.setColor( alternateTextColor);874 g.setFont(SwingMiscManager.getIfUsingSwingFontManager().getInternalFont(TrackWidgetCommons.FREESPACE_TRACKNAME_FONT)); 875 g.setColor(SwingConversions.toSwingColor(alternateTextColor)); 874 876 875 877 // Center track name 876 FontMetrics fm = g.getFontMetrics( TrackWidgetCommons.FREESPACE_TRACKNAME_FONT);878 FontMetrics fm = g.getFontMetrics(SwingMiscManager.getIfUsingSwingFontManager().getInternalFont(TrackWidgetCommons.FREESPACE_TRACKNAME_FONT)); 877 879 Rectangle2D rect = fm.getStringBounds(alternateText, g); 878 880 … … 907 909 908 910 // Render backcolor 909 imageGraphics.setColor( GRAPH_BACKCOLOR);911 imageGraphics.setColor(SwingConversions.toSwingColor(GRAPH_BACKCOLOR)); 910 912 imageGraphics.fillRect(GRAPH_WIDTH - pixelWidth, 0, pixelWidth, GRAPH_HEIGHT); 911 913 912 914 // Render wave forms from lastSampleHeight 913 imageGraphics.setColor( GRAPH_WAVECOLOR);915 imageGraphics.setColor(SwingConversions.toSwingColor(GRAPH_WAVECOLOR)); 914 916 int currentPixelX = GRAPH_WIDTH - pixelWidth; 915 917 … … 933 935 Rectangle dirty = this.getBounds(); 934 936 dirty.translate(SampleRecorder.this.getX(), SampleRecorder.this.getY()); 935 FrameGraphics.invalidateArea(dirty);936 FrameGraphics.refresh(true);937 DisplayController.invalidateArea(SwingConversions.fromSwingRectangle(dirty)); 938 DisplayController.requestRefresh(true); 937 939 938 940 } … … 979 981 sampleGraph.alternateText = Integer.toString(currentCountdown); 980 982 sampleGraph.alternateTextColor = (currentCountdown > 3) ? 981 Colo r.WHITE : Color.RED;983 Colour.WHITE : Colour.RED; 982 984 sampleGraph.invalidateGraph(); 983 FrameGraphics.refresh(true);985 DisplayController.requestRefresh(true); 984 986 } 985 987 });
Note:
See TracChangeset
for help on using the changeset viewer.