From 372d97fee538f86c8333fbbde43cf51484b8ac67 Mon Sep 17 00:00:00 2001 From: sowgro Date: Sat, 6 May 2023 14:56:46 -0400 Subject: Add JavaFX and seperate source and class files --- .classpath | 10 - .project | 28 -- .settings/org.eclipse.core.resources.prefs | 2 - .settings/org.eclipse.jdt.core.prefs | 14 - .vscode/launch.json | 15 + .vscode/settings.json | 6 +- apcs/Driver.java | 18 - apcs/Gui.java | 41 --- apcs/KeyDetection.java | 27 -- apcs/NoteTest.java | 35 -- apcs/RoundedRectangleTest.java | 91 ----- apcs/ShortAudioFilePlayer.java | 96 ----- apcs/SongPlayer.java | 97 ----- apcs/TButton.java | 30 -- apcs/block.java | 86 ----- apcs/shadowtest.java | 26 -- dropShadow/GraphicsUtilities.java | 555 ----------------------------- dropShadow/Main.form | 96 ----- dropShadow/Main.java | 125 ------- dropShadow/PanelShadow.java | 100 ------ dropShadow/ShadowRenderer.java | 185 ---------- dropShadow/ShadowType.java | 5 - lib/javafx-swt.jar | Bin 0 -> 37117 bytes lib/javafx.base.jar | Bin 0 -> 755038 bytes lib/javafx.controls.jar | Bin 0 -> 2577993 bytes lib/javafx.fxml.jar | Bin 0 -> 130176 bytes lib/javafx.graphics.jar | Bin 0 -> 4339873 bytes lib/javafx.media.jar | Bin 0 -> 278549 bytes lib/javafx.properties | 3 + lib/javafx.swing.jar | Bin 0 -> 89688 bytes lib/javafx.web.jar | Bin 0 -> 727749 bytes lib/libavplugin-54.so | Bin 0 -> 52160 bytes lib/libavplugin-56.so | Bin 0 -> 52360 bytes lib/libavplugin-57.so | Bin 0 -> 52360 bytes lib/libavplugin-ffmpeg-56.so | Bin 0 -> 52360 bytes lib/libavplugin-ffmpeg-57.so | Bin 0 -> 52360 bytes lib/libavplugin-ffmpeg-58.so | Bin 0 -> 52360 bytes lib/libavplugin-ffmpeg-59.so | Bin 0 -> 52272 bytes lib/libdecora_sse.so | Bin 0 -> 73672 bytes lib/libfxplugins.so | Bin 0 -> 51752 bytes lib/libglass.so | Bin 0 -> 11568 bytes lib/libglassgtk2.so | Bin 0 -> 328520 bytes lib/libglassgtk3.so | Bin 0 -> 328864 bytes lib/libgstreamer-lite.so | Bin 0 -> 2187712 bytes lib/libjavafx_font.so | Bin 0 -> 15992 bytes lib/libjavafx_font_freetype.so | Bin 0 -> 25928 bytes lib/libjavafx_font_pango.so | Bin 0 -> 24424 bytes lib/libjavafx_iio.so | Bin 0 -> 140496 bytes lib/libjfxmedia.so | Bin 0 -> 530144 bytes lib/libjfxwebkit.so | Bin 0 -> 99198016 bytes lib/libprism_common.so | Bin 0 -> 7048 bytes lib/libprism_es2.so | Bin 0 -> 62480 bytes lib/libprism_sw.so | Bin 0 -> 64960 bytes src/main/AudioFilePlayer.java | 96 +++++ src/main/Driver.java | 19 + src/main/Gui.java | 41 +++ src/main/KeyDetection.java | 27 ++ src/main/NoteTest.java | 35 ++ src/main/RoundedRectangleTest.java | 92 +++++ src/main/SongPlayer.java | 97 +++++ src/main/TButton.java | 30 ++ src/main/block.java | 85 +++++ src/main/jfxTest.java | 35 ++ src/main/shadowtest.java | 40 +++ 64 files changed, 620 insertions(+), 1668 deletions(-) delete mode 100644 .classpath delete mode 100644 .project delete mode 100644 .settings/org.eclipse.core.resources.prefs delete mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .vscode/launch.json delete mode 100644 apcs/Driver.java delete mode 100644 apcs/Gui.java delete mode 100644 apcs/KeyDetection.java delete mode 100644 apcs/NoteTest.java delete mode 100644 apcs/RoundedRectangleTest.java delete mode 100644 apcs/ShortAudioFilePlayer.java delete mode 100644 apcs/SongPlayer.java delete mode 100644 apcs/TButton.java delete mode 100644 apcs/block.java delete mode 100644 apcs/shadowtest.java delete mode 100644 dropShadow/GraphicsUtilities.java delete mode 100644 dropShadow/Main.form delete mode 100644 dropShadow/Main.java delete mode 100644 dropShadow/PanelShadow.java delete mode 100644 dropShadow/ShadowRenderer.java delete mode 100644 dropShadow/ShadowType.java create mode 100644 lib/javafx-swt.jar create mode 100644 lib/javafx.base.jar create mode 100644 lib/javafx.controls.jar create mode 100644 lib/javafx.fxml.jar create mode 100644 lib/javafx.graphics.jar create mode 100644 lib/javafx.media.jar create mode 100644 lib/javafx.properties create mode 100644 lib/javafx.swing.jar create mode 100644 lib/javafx.web.jar create mode 100755 lib/libavplugin-54.so create mode 100755 lib/libavplugin-56.so create mode 100755 lib/libavplugin-57.so create mode 100755 lib/libavplugin-ffmpeg-56.so create mode 100755 lib/libavplugin-ffmpeg-57.so create mode 100755 lib/libavplugin-ffmpeg-58.so create mode 100755 lib/libavplugin-ffmpeg-59.so create mode 100755 lib/libdecora_sse.so create mode 100755 lib/libfxplugins.so create mode 100755 lib/libglass.so create mode 100755 lib/libglassgtk2.so create mode 100755 lib/libglassgtk3.so create mode 100755 lib/libgstreamer-lite.so create mode 100755 lib/libjavafx_font.so create mode 100755 lib/libjavafx_font_freetype.so create mode 100755 lib/libjavafx_font_pango.so create mode 100755 lib/libjavafx_iio.so create mode 100755 lib/libjfxmedia.so create mode 100755 lib/libjfxwebkit.so create mode 100755 lib/libprism_common.so create mode 100755 lib/libprism_es2.so create mode 100755 lib/libprism_sw.so create mode 100644 src/main/AudioFilePlayer.java create mode 100644 src/main/Driver.java create mode 100644 src/main/Gui.java create mode 100644 src/main/KeyDetection.java create mode 100644 src/main/NoteTest.java create mode 100644 src/main/RoundedRectangleTest.java create mode 100644 src/main/SongPlayer.java create mode 100644 src/main/TButton.java create mode 100644 src/main/block.java create mode 100644 src/main/jfxTest.java create mode 100644 src/main/shadowtest.java diff --git a/.classpath b/.classpath deleted file mode 100644 index c53469e..0000000 --- a/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/.project b/.project deleted file mode 100644 index e31f76a..0000000 --- a/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - GuitarHero - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - - - 1682561836288 - - 30 - - org.eclipse.core.resources.regexFilterMatcher - node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ - - - - diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c0..0000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f2525a8..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,14 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=11 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3d52c67 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Launch App", + "request": "launch", + "mainClass": "main.jfxTest", + "vmArgs": "--module-path lib --add-modules javafx.controls,javafx.fxml", + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index c995aa5..c9eadff 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,7 @@ { - "java.debug.settings.onBuildFailureProceed": true + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] } \ No newline at end of file diff --git a/apcs/Driver.java b/apcs/Driver.java deleted file mode 100644 index 7b053e4..0000000 --- a/apcs/Driver.java +++ /dev/null @@ -1,18 +0,0 @@ -/*Name: - *Date: - *Period: - *Teacher: - *Description: - */ -package apcs; - - -public class Driver -{ - - public static void main(String[] args) - { - new RoundedRectangleTest(); - } - -} diff --git a/apcs/Gui.java b/apcs/Gui.java deleted file mode 100644 index 934c371..0000000 --- a/apcs/Gui.java +++ /dev/null @@ -1,41 +0,0 @@ -/*Name: - *Date: - *Period: - *Teacher: - *Description: - */ -package apcs; - -import javax.swing.JButton; -import javax.swing.JFrame; -public class Gui { - public Gui() - { - /* JFrame is a top level container (window) - * where we would be adding our button - */ - JFrame frame=new JFrame(); - - // Creating Button - JButton b=new JButton("Click Me.."); - /* This method specifies the location and size - * of button. In method setBounds(x, y, width, height) - * x,y) are cordinates from the top left - * corner and remaining two arguments are the width - * and height of the button. - */ - b.setBounds(50,50,200, 50); - - //Adding button onto the frame - frame.add(b); - - // Setting Frame size. This is the window size - frame.setSize(600,500); - - frame.setLayout(null); - frame.setVisible(true); - - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - } -} diff --git a/apcs/KeyDetection.java b/apcs/KeyDetection.java deleted file mode 100644 index 9fc9db6..0000000 --- a/apcs/KeyDetection.java +++ /dev/null @@ -1,27 +0,0 @@ -/*Name: - *Date: - *Period: - *Teacher: - *Description: - */ -package apcs; - -import javax.swing.*; -import java.awt.event.ActionEvent; - -public class KeyDetection extends AbstractAction -{ - long timeStart = System.currentTimeMillis(); - private char key; - public KeyDetection(char ch){ - key = ch; - } - - public void actionPerformed(ActionEvent e) - { - // TODO Auto-generated method stub - int time = (int)((System.currentTimeMillis()-timeStart)); - System.out.println(key + ": " + time); - } - -} diff --git a/apcs/NoteTest.java b/apcs/NoteTest.java deleted file mode 100644 index 310325b..0000000 --- a/apcs/NoteTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/*Name: - *Date: - *Period: - *Teacher: - *Description: - */ -package apcs; -import java.awt.*; - -public class NoteTest -{ - private boolean failed = false; - private int lane; - private final int NOTESPEED = 1; - private int yPos = SongPlayer.HEIGHT; - - public void gameTick() { - if (!failed) { - if (yPos > 0) { - yPos -= NOTESPEED; - } - else { - failed = true; - } - } - } - - public boolean getFailed() { - return failed; - } - - public int getY() { - return yPos; - } -} diff --git a/apcs/RoundedRectangleTest.java b/apcs/RoundedRectangleTest.java deleted file mode 100644 index c24772c..0000000 --- a/apcs/RoundedRectangleTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package apcs; - -import java.awt.*; -import java.awt.event.*; -import java.awt.geom.AffineTransform; -import java.awt.geom.RoundRectangle2D; - -import javax.swing.*; - -public class RoundedRectangleTest extends JFrame { - public RoundedRectangleTest() { - setTitle("RoundedRectangle Test"); - setSize(350, 275); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setLocationRelativeTo(null); - setVisible(true); - } - public void paint(Graphics g) { - //DropShadowBorder shadow = new DropShadowBorder(); - - Graphics2D g2d = (Graphics2D) g; - g2d.setPaint(Color.DARK_GRAY); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.fillRoundRect(10, 50, 150, 150, 30, 30); // to draw a rounded rectangle. - - /*Graphics2D g2d = (Graphics2D) g; - Color holdColor = g2d.getColor(); - g2d.setColor(Color.black); - AffineTransform holdTransform = g2d.getTransform(); - // want the shadow to be one line width pixel offset - float lineWidth; - if (g2d.getStroke() instanceof BasicStroke) - { - lineWidth = ((BasicStroke) (g2d.getStroke())).getLineWidth(); - } - else - { - lineWidth = 1.0f; - } - //System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth); - //g2d.translate(lineWidth, lineWidth); - g2d.fillRoundRect(10, 50, 150, 150, 30, 30); - //g2d.setColor(holdColor); - //g2d.setTransform(holdTransform); - //g2d.drawRoundRect(10, 50, 150, 150, 30, 30); - */ - - - } - public static void main(String []args) { - new RoundedRectangleTest(); - } - - public static void drawShadowedShape(Shape shape, Graphics2D g2d) - { - Color holdColor = g2d.getColor(); - g2d.setColor(Color.black); - AffineTransform holdTransform = g2d.getTransform(); - // want the shadow to be one line width pixel offset - float lineWidth; - if (g2d.getStroke() instanceof BasicStroke) - { - lineWidth = ((BasicStroke) (g2d.getStroke())).getLineWidth(); - } - else - { - lineWidth = 1.0f; - } - //System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth); - g2d.translate(lineWidth, lineWidth); - g2d.draw(shape); - g2d.setColor(holdColor); - g2d.setTransform(holdTransform); - g2d.draw(shape); - } - - public static void drawShadowedShape2(Shape shape, Graphics2D g2d) { - Color holdColor = g2d.getColor(); - g2d.setColor(Color.black); - AffineTransform holdTransform = g2d.getTransform(); - // want the shadow to be one line width pixel offset - float lineWidth = g2d.getStroke() instanceof BasicStroke ? ((BasicStroke) (g2d.getStroke())).getLineWidth() - : 1.0f; - //System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth); - g2d.translate(lineWidth, lineWidth); - g2d.draw(shape); - g2d.setColor(holdColor); - g2d.setTransform(holdTransform); - g2d.draw(shape); - } -} \ No newline at end of file diff --git a/apcs/ShortAudioFilePlayer.java b/apcs/ShortAudioFilePlayer.java deleted file mode 100644 index 0a03c9c..0000000 --- a/apcs/ShortAudioFilePlayer.java +++ /dev/null @@ -1,96 +0,0 @@ -package apcs; -//Java program to play audio files. imports file scanning and various -//methods from the java audio class in order to do so. -import java.io.File; -import java.io.IOException; - -import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Clip; -import javax.sound.sampled.DataLine; -import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineListener; -import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.UnsupportedAudioFileException; - -public class AudioFilePlayer implements LineListener -{ - //indicates whether the playback completes or not - boolean playCompleted; - Clip audioClip; - - public void play(String audioFilePath) - { - File audioFile = new File(audioFilePath); - - try - { - //creates an audioInput object using the file we - //declared earlier - AudioInputStream audioStream = AudioSystem.getAudioInputStream(audioFile); - - //gets the format of the audioStream object - AudioFormat format = audioStream.getFormat(); - - DataLine.Info info = new DataLine.Info(Clip.class, format); - - audioClip = (Clip) AudioSystem.getLine(info); - - audioClip.addLineListener(this); - - audioClip.open(audioStream); - - audioClip.start(); - - while (!playCompleted) - { - // wait for the playback to complete - try - { - Thread.sleep(1000); - } - catch (InterruptedException ex) - { - ex.printStackTrace(); - } - } - audioClip.close(); //stops the audio clip - } - catch (UnsupportedAudioFileException ex) - { - System.out.println("The specified audio file is not supported."); - ex.printStackTrace(); - } - catch (LineUnavailableException ex) - { - System.out.println("Audio line for playing back is unavailable."); - ex.printStackTrace(); - } - catch (IOException ex) - { - System.out.println("Error playing the audio file."); - ex.printStackTrace(); - } - } - - - /** - * Listens to the START and STOP events of the audio line. - */ - @Override - public void update(LineEvent event) - { - LineEvent.Type type = event.getType(); - - if (type == LineEvent.Type.START) - { - System.out.println("Playback started."); - } - else if (type == LineEvent.Type.STOP) - { - playCompleted = true; - System.out.println("Playback completed."); - } - } -} diff --git a/apcs/SongPlayer.java b/apcs/SongPlayer.java deleted file mode 100644 index 686bc7c..0000000 --- a/apcs/SongPlayer.java +++ /dev/null @@ -1,97 +0,0 @@ -/*Name: - *Date: - *Period: - *Teacher: - *Description: - */ -package apcs; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - - -public class SongPlayer -{ - public static final int HEIGHT = 650; - public static final int LENGTH = 400; - - - private final int BLENGTH = LENGTH/6; - private final int BHEIGHT = HEIGHT/20; - JFrame frame = new JFrame("Guitar Hero"); //creates the frame - - - JButton d = new JButton("D"); //creates the four button lanes - JButton f = new JButton("F"); - JButton h = new JButton("H"); - JButton j = new JButton("J"); - - - public void createAndShowGui() { - - d.setBounds(1*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); //makes the button bounds for each button - f.setBounds(2*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); - h.setBounds(3*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); - j.setBounds(4*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); - - - frame.add(d); //adds the buttons to the frame - frame.add(f); - frame.add(h); - frame.add(j); - - frame.setSize(LENGTH, HEIGHT); //sets the size of the frame - frame.setLayout(null); //??? - frame.setVisible(true); //makes the frame visible - - KeyDetection dAction = new KeyDetection('d'); //creates an action for each char - d.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('d'), "dPress"); //Input map and Action map setting - d.getActionMap().put("dPress", dAction); - d.setFocusable(false); //makes it so you can't highlight the button - - KeyDetection fAction = new KeyDetection('f'); - f.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('f'), "fPress"); - f.getActionMap().put("fPress", fAction); - f.setFocusable(false); - - KeyDetection hAction = new KeyDetection('h'); - h.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('h'), "hPress"); - h.getActionMap().put("hPress", hAction); - h.setFocusable(false); - - KeyDetection jAction = new KeyDetection('j'); - j.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('j'), "jPress"); - j.getActionMap().put("jPress", jAction); - j.setFocusable(false); - } - - public void loop() { - JButton note = new JButton(); - JButton test = new JButton(); - test.setBounds(200, 200, 100, 100); - note.setBounds(BLENGTH, 0, BLENGTH, BHEIGHT); - frame.add(note); - frame.add(test); - - NoteTest a = new NoteTest(); - while (!a.getFailed()) { - if (!a.getFailed()) { - a.gameTick(); - note.setBounds(BLENGTH, HEIGHT-a.getY(), BLENGTH, BHEIGHT); //moves the note down every frame - System.out.println(a.getFailed()); - //the computer runs too fast normally, force it to run at a certain fps - try { - Thread.sleep(2); - } catch (InterruptedException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - if (a.getFailed()) { - frame.remove(note); //removes the note once its off the screen - } - } - } -} diff --git a/apcs/TButton.java b/apcs/TButton.java deleted file mode 100644 index 7583726..0000000 --- a/apcs/TButton.java +++ /dev/null @@ -1,30 +0,0 @@ -package apcs; - -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.Color; -import java.awt.Graphics; - -public class TButton extends JButton{ - public TButton(String text) { - super(text); - super.setContentAreaFilled(false); - } - - @Override - protected void paintComponent(Graphics g) { - Color temp = super.getBackground(); - if (getModel().isPressed()) { - g.setColor(temp.darker().darker()); - } else if (getModel().isRollover()) { - g.setColor(temp.darker()); - } else { - g.setColor(temp); - } - g.fillRect(0, 0, getWidth(), getHeight()); - super.paintComponent(g); - super.setBorderPainted(false); - } -} diff --git a/apcs/block.java b/apcs/block.java deleted file mode 100644 index 97dbf75..0000000 --- a/apcs/block.java +++ /dev/null @@ -1,86 +0,0 @@ -package apcs; - -import java.awt.Dimension; -import java.awt.EventQueue; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.awt.geom.Path2D; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; -import javafx.scene.effect.DropShadow; - -// - -public class block { - - public static void main(String[] args) { - new block(); - } - - public block() { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - /*try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { - ex.printStackTrace(); - } - */ - - JFrame frame = new JFrame("Testing"); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.add(new TestPane()); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - - } - }); - } - - public class TestPane extends JPanel { - - private RightEnd rightEnd; - - public TestPane() { - rightEnd = new RightEnd(100, 100, 40); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(100, 100); - } - - - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - int x = (getWidth() - 100) / 2; - int y = (getHeight()- 100) / 2; - Graphics2D g2d = (Graphics2D) g.create(); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.translate(x, y); - g2d.fill(rightEnd); - g2d.dispose(); - } - - - } - - public class RightEnd extends Path2D.Float { - - public RightEnd(float width, float height, float radius) { - moveTo(0, 0); - lineTo(width - radius, 0); - curveTo(width, 0, width, 0, width, radius); - lineTo(width, height - radius); - curveTo(width, height, width, height, width - radius, height); - lineTo(0, height); - closePath(); - } - } -} diff --git a/apcs/shadowtest.java b/apcs/shadowtest.java deleted file mode 100644 index b6acba5..0000000 --- a/apcs/shadowtest.java +++ /dev/null @@ -1,26 +0,0 @@ -package apcs; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Graphics2D; - -import java.awt.Shape; - -import java.awt.geom.AffineTransform; - -public class shadowtest { - public static void drawShadowedShape(Shape shape, Graphics2D g2d) { - Color holdColor = g2d.getColor(); - g2d.setColor(Color.black); - AffineTransform holdTransform = g2d.getTransform(); - // want the shadow to be one line width pixel offset - float lineWidth = g2d.getStroke() instanceof BasicStroke ? ((BasicStroke) (g2d.getStroke())).getLineWidth() - : 1.0f; - //System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth); - g2d.translate(lineWidth, lineWidth); - g2d.draw(shape); - g2d.setColor(holdColor); - g2d.setTransform(holdTransform); - g2d.draw(shape); - } -} \ No newline at end of file diff --git a/dropShadow/GraphicsUtilities.java b/dropShadow/GraphicsUtilities.java deleted file mode 100644 index 832e59b..0000000 --- a/dropShadow/GraphicsUtilities.java +++ /dev/null @@ -1,555 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package dropShadow; - -import java.awt.image.BufferedImage; -import java.awt.image.ColorModel; -import java.awt.image.Raster; -import java.awt.image.WritableRaster; -import java.awt.GraphicsConfiguration; -import java.awt.Transparency; -import java.awt.Graphics; -import java.awt.GraphicsEnvironment; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.io.IOException; -import java.net.URL; -import javax.imageio.ImageIO; - -/** - *

- * GraphicsUtilities contains a set of tools to perform common - * graphics operations easily. These operations are divided into several themes, - * listed below.

- *

Compatible Images

- *

- * Compatible images can, and should, be used to increase drawing performance. - * This class provides a number of methods to load compatible images directly - * from files or to convert existing images to compatibles images.

- *

Creating Thumbnails

- *

- * This class provides a number of methods to easily scale down images. Some of - * these methods offer a trade-off between speed and result quality and shouuld - * be used all the time. They also offer the advantage of producing compatible - * images, thus automatically resulting into better runtime performance.

- *

- * All these methodes are both faster than - * {@link java.awt.Image#getScaledInstance(int, int, int)} and produce - * better-looking results than the various drawImage() methods in - * {@link java.awt.Graphics}, which can be used for image scaling.

- *

Image Manipulation

- *

- * This class provides two methods to get and set pixels in a buffered image. - * These methods try to avoid unmanaging the image in order to keep good - * performance.

- * - * @author Romain Guy - */ -public class GraphicsUtilities { - - private GraphicsUtilities() { - } - - // Returns the graphics configuration for the primary screen - private static GraphicsConfiguration getGraphicsConfiguration() { - return GraphicsEnvironment.getLocalGraphicsEnvironment(). - getDefaultScreenDevice().getDefaultConfiguration(); - } - - /** - *

- * Returns a new BufferedImage using the same color model as - * the image passed as a parameter. The returned image is only compatible - * with the image passed as a parameter. This does not mean the returned - * image is compatible with the hardware.

- * - * @param image the reference image from which the color model of the new - * image is obtained - * @return a new BufferedImage, compatible with the color model - * of image - */ - public static BufferedImage createColorModelCompatibleImage(BufferedImage image) { - ColorModel cm = image.getColorModel(); - return new BufferedImage(cm, - cm.createCompatibleWritableRaster(image.getWidth(), - image.getHeight()), - cm.isAlphaPremultiplied(), null); - } - - /** - *

- * Returns a new compatible image with the same width, height and - * transparency as the image specified as a parameter.

- * - * @see java.awt.Transparency - * @see #createCompatibleImage(int, int) - * @see #createCompatibleImage(java.awt.image.BufferedImage, int, int) - * @see #createCompatibleTranslucentImage(int, int) - * @see #loadCompatibleImage(java.net.URL) - * @see #toCompatibleImage(java.awt.image.BufferedImage) - * @param image the reference image from which the dimension and the - * transparency of the new image are obtained - * @return a new compatible BufferedImage with the same - * dimension and transparency as image - */ - public static BufferedImage createCompatibleImage(BufferedImage image) { - return createCompatibleImage(image, image.getWidth(), image.getHeight()); - } - - /** - *

- * Returns a new compatible image of the specified width and height, and the - * same transparency setting as the image specified as a parameter.

- * - * @see java.awt.Transparency - * @see #createCompatibleImage(java.awt.image.BufferedImage) - * @see #createCompatibleImage(int, int) - * @see #createCompatibleTranslucentImage(int, int) - * @see #loadCompatibleImage(java.net.URL) - * @see #toCompatibleImage(java.awt.image.BufferedImage) - * @param width the width of the new image - * @param height the height of the new image - * @param image the reference image from which the transparency of the new - * image is obtained - * @return a new compatible BufferedImage with the same - * transparency as image and the specified dimension - */ - public static BufferedImage createCompatibleImage(BufferedImage image, - int width, int height) { - return getGraphicsConfiguration().createCompatibleImage(width, height, - image.getTransparency()); - } - - /** - *

- * Returns a new opaque compatible image of the specified width and - * height.

- * - * @see #createCompatibleImage(java.awt.image.BufferedImage) - * @see #createCompatibleImage(java.awt.image.BufferedImage, int, int) - * @see #createCompatibleTranslucentImage(int, int) - * @see #loadCompatibleImage(java.net.URL) - * @see #toCompatibleImage(java.awt.image.BufferedImage) - * @param width the width of the new image - * @param height the height of the new image - * @return a new opaque compatible BufferedImage of the - * specified width and height - */ - public static BufferedImage createCompatibleImage(int width, int height) { - return getGraphicsConfiguration().createCompatibleImage(width, height); - } - - /** - *

- * Returns a new translucent compatible image of the specified width and - * height.

- * - * @see #createCompatibleImage(java.awt.image.BufferedImage) - * @see #createCompatibleImage(java.awt.image.BufferedImage, int, int) - * @see #createCompatibleImage(int, int) - * @see #loadCompatibleImage(java.net.URL) - * @see #toCompatibleImage(java.awt.image.BufferedImage) - * @param width the width of the new image - * @param height the height of the new image - * @return a new translucent compatible BufferedImage of the - * specified width and height - */ - public static BufferedImage createCompatibleTranslucentImage(int width, - int height) { - return getGraphicsConfiguration().createCompatibleImage(width, height, - Transparency.TRANSLUCENT); - } - - /** - *

- * Returns a new compatible image from a URL. The image is loaded from the - * specified location and then turned, if necessary into a compatible - * image.

- * - * @see #createCompatibleImage(java.awt.image.BufferedImage) - * @see #createCompatibleImage(java.awt.image.BufferedImage, int, int) - * @see #createCompatibleImage(int, int) - * @see #createCompatibleTranslucentImage(int, int) - * @see #toCompatibleImage(java.awt.image.BufferedImage) - * @param resource the URL of the picture to load as a compatible image - * @return a new translucent compatible BufferedImage of the - * specified width and height - * @throws java.io.IOException if the image cannot be read or loaded - */ - public static BufferedImage loadCompatibleImage(URL resource) - throws IOException { - BufferedImage image = ImageIO.read(resource); - return toCompatibleImage(image); - } - - /** - *

- * Return a new compatible image that contains a copy of the specified - * image. This method ensures an image is compatible with the hardware, and - * therefore optimized for fast blitting operations.

- * - * @see #createCompatibleImage(java.awt.image.BufferedImage) - * @see #createCompatibleImage(java.awt.image.BufferedImage, int, int) - * @see #createCompatibleImage(int, int) - * @see #createCompatibleTranslucentImage(int, int) - * @see #loadCompatibleImage(java.net.URL) - * @param image the image to copy into a new compatible image - * @return a new compatible copy, with the same width and height and - * transparency and content, of image - */ - public static BufferedImage toCompatibleImage(BufferedImage image) { - if (image.getColorModel().equals( - getGraphicsConfiguration().getColorModel())) { - return image; - } - - BufferedImage compatibleImage - = getGraphicsConfiguration().createCompatibleImage( - image.getWidth(), image.getHeight(), - image.getTransparency()); - Graphics g = compatibleImage.getGraphics(); - g.drawImage(image, 0, 0, null); - g.dispose(); - - return compatibleImage; - } - - /** - *

- * Returns a thumbnail of a source image. newSize defines the - * length of the longest dimension of the thumbnail. The other dimension is - * then computed according to the dimensions ratio of the original - * picture.

- *

- * This method favors speed over quality. When the new size is less than - * half the longest dimension of the source image, - * {@link #createThumbnail(BufferedImage, int)} or - * {@link #createThumbnail(BufferedImage, int, int)} should be used instead - * to ensure the quality of the result without sacrificing too much - * performance.

- * - * @see #createThumbnailFast(java.awt.image.BufferedImage, int, int) - * @see #createThumbnail(java.awt.image.BufferedImage, int) - * @see #createThumbnail(java.awt.image.BufferedImage, int, int) - * @param image the source image - * @param newSize the length of the largest dimension of the thumbnail - * @return a new compatible BufferedImage containing a - * thumbnail of image - * @throws IllegalArgumentException if newSize is larger than - * the largest dimension of image or <= 0 - */ - public static BufferedImage createThumbnailFast(BufferedImage image, - int newSize) { - float ratio; - int width = image.getWidth(); - int height = image.getHeight(); - - if (width > height) { - if (newSize >= width) { - throw new IllegalArgumentException("newSize must be lower than" - + " the image width"); - } else if (newSize <= 0) { - throw new IllegalArgumentException("newSize must" - + " be greater than 0"); - } - - ratio = (float) width / (float) height; - width = newSize; - height = (int) (newSize / ratio); - } else { - if (newSize >= height) { - throw new IllegalArgumentException("newSize must be lower than" - + " the image height"); - } else if (newSize <= 0) { - throw new IllegalArgumentException("newSize must" - + " be greater than 0"); - } - - ratio = (float) height / (float) width; - height = newSize; - width = (int) (newSize / ratio); - } - - BufferedImage temp = createCompatibleImage(image, width, height); - Graphics2D g2 = temp.createGraphics(); - g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - g2.drawImage(image, 0, 0, temp.getWidth(), temp.getHeight(), null); - g2.dispose(); - - return temp; - } - - /** - *

- * Returns a thumbnail of a source image.

- *

- * This method favors speed over quality. When the new size is less than - * half the longest dimension of the source image, - * {@link #createThumbnail(BufferedImage, int)} or - * {@link #createThumbnail(BufferedImage, int, int)} should be used instead - * to ensure the quality of the result without sacrificing too much - * performance.

- * - * @see #createThumbnailFast(java.awt.image.BufferedImage, int) - * @see #createThumbnail(java.awt.image.BufferedImage, int) - * @see #createThumbnail(java.awt.image.BufferedImage, int, int) - * @param image the source image - * @param newWidth the width of the thumbnail - * @param newHeight the height of the thumbnail - * @return a new compatible BufferedImage containing a - * thumbnail of image - * @throws IllegalArgumentException if newWidth is larger than - * the width of image or if code>newHeight is larger - * than the height of image or if one of the dimensions is - * <= 0 - */ - public static BufferedImage createThumbnailFast(BufferedImage image, - int newWidth, int newHeight) { - if (newWidth >= image.getWidth() - || newHeight >= image.getHeight()) { - throw new IllegalArgumentException("newWidth and newHeight cannot" - + " be greater than the image" - + " dimensions"); - } else if (newWidth <= 0 || newHeight <= 0) { - throw new IllegalArgumentException("newWidth and newHeight must" - + " be greater than 0"); - } - - BufferedImage temp = createCompatibleImage(image, newWidth, newHeight); - Graphics2D g2 = temp.createGraphics(); - g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - g2.drawImage(image, 0, 0, temp.getWidth(), temp.getHeight(), null); - g2.dispose(); - - return temp; - } - - /** - *

- * Returns a thumbnail of a source image. newSize defines the - * length of the longest dimension of the thumbnail. The other dimension is - * then computed according to the dimensions ratio of the original - * picture.

- *

- * This method offers a good trade-off between speed and quality. The result - * looks better than - * {@link #createThumbnailFast(java.awt.image.BufferedImage, int)} when the - * new size is less than half the longest dimension of the source image, yet - * the rendering speed is almost similar.

- * - * @see #createThumbnailFast(java.awt.image.BufferedImage, int, int) - * @see #createThumbnailFast(java.awt.image.BufferedImage, int) - * @see #createThumbnail(java.awt.image.BufferedImage, int, int) - * @param image the source image - * @param newSize the length of the largest dimension of the thumbnail - * @return a new compatible BufferedImage containing a - * thumbnail of image - * @throws IllegalArgumentException if newSize is larger than - * the largest dimension of image or <= 0 - */ - public static BufferedImage createThumbnail(BufferedImage image, - int newSize) { - int width = image.getWidth(); - int height = image.getHeight(); - - boolean isWidthGreater = width > height; - - if (isWidthGreater) { - if (newSize >= width) { - throw new IllegalArgumentException("newSize must be lower than" - + " the image width"); - } - } else if (newSize >= height) { - throw new IllegalArgumentException("newSize must be lower than" - + " the image height"); - } - - if (newSize <= 0) { - throw new IllegalArgumentException("newSize must" - + " be greater than 0"); - } - - float ratioWH = (float) width / (float) height; - float ratioHW = (float) height / (float) width; - - BufferedImage thumb = image; - - do { - if (isWidthGreater) { - width /= 2; - if (width < newSize) { - width = newSize; - } - height = (int) (width / ratioWH); - } else { - height /= 2; - if (height < newSize) { - height = newSize; - } - width = (int) (height / ratioHW); - } - - BufferedImage temp = createCompatibleImage(image, width, height); - Graphics2D g2 = temp.createGraphics(); - g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - g2.drawImage(thumb, 0, 0, temp.getWidth(), temp.getHeight(), null); - g2.dispose(); - - thumb = temp; - } while (newSize != (isWidthGreater ? width : height)); - - return thumb; - } - - /** - *

- * Returns a thumbnail of a source image.

- *

- * This method offers a good trade-off between speed and quality. The result - * looks better than - * {@link #createThumbnailFast(java.awt.image.BufferedImage, int)} when the - * new size is less than half the longest dimension of the source image, yet - * the rendering speed is almost similar.

- * - * @see #createThumbnailFast(java.awt.image.BufferedImage, int) - * @see #createThumbnailFast(java.awt.image.BufferedImage, int, int) - * @see #createThumbnail(java.awt.image.BufferedImage, int) - * @param image the source image - * @param newWidth the width of the thumbnail - * @param newHeight the height of the thumbnail - * @return a new compatible BufferedImage containing a - * thumbnail of image - * @throws IllegalArgumentException if newWidth is larger than - * the width of image or if code>newHeight is larger - * than the height of - * image or if one the dimensions is not > 0 - */ - public static BufferedImage createThumbnail(BufferedImage image, - int newWidth, int newHeight) { - int width = image.getWidth(); - int height = image.getHeight(); - - if (newWidth >= width || newHeight >= height) { - throw new IllegalArgumentException("newWidth and newHeight cannot" - + " be greater than the image" - + " dimensions"); - } else if (newWidth <= 0 || newHeight <= 0) { - throw new IllegalArgumentException("newWidth and newHeight must" - + " be greater than 0"); - } - - BufferedImage thumb = image; - - do { - if (width > newWidth) { - width /= 2; - if (width < newWidth) { - width = newWidth; - } - } - - if (height > newHeight) { - height /= 2; - if (height < newHeight) { - height = newHeight; - } - } - - BufferedImage temp = createCompatibleImage(image, width, height); - Graphics2D g2 = temp.createGraphics(); - g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - g2.drawImage(thumb, 0, 0, temp.getWidth(), temp.getHeight(), null); - g2.dispose(); - - thumb = temp; - } while (width != newWidth || height != newHeight); - - return thumb; - } - - /** - *

- * Returns an array of pixels, stored as integers, from a - * BufferedImage. The pixels are grabbed from a rectangular - * area defined by a location and two dimensions. Calling this method on an - * image of type different from BufferedImage.TYPE_INT_ARGB and - * BufferedImage.TYPE_INT_RGB will unmanage the image.

- * - * @param img the source image - * @param x the x location at which to start grabbing pixels - * @param y the y location at which to start grabbing pixels - * @param w the width of the rectangle of pixels to grab - * @param h the height of the rectangle of pixels to grab - * @param pixels a pre-allocated array of pixels of size w*h; can be null - * @return pixels if non-null, a new array of integers - * otherwise - * @throws IllegalArgumentException is pixels is non-null and - * of length < w*h - */ - public static int[] getPixels(BufferedImage img, - int x, int y, int w, int h, int[] pixels) { - if (w == 0 || h == 0) { - return new int[0]; - } - - if (pixels == null) { - pixels = new int[w * h]; - } else if (pixels.length < w * h) { - throw new IllegalArgumentException("pixels array must have a length" - + " >= w*h"); - } - - int imageType = img.getType(); - if (imageType == BufferedImage.TYPE_INT_ARGB - || imageType == BufferedImage.TYPE_INT_RGB) { - Raster raster = img.getRaster(); - return (int[]) raster.getDataElements(x, y, w, h, pixels); - } - - // Unmanages the image - return img.getRGB(x, y, w, h, pixels, 0, w); - } - - /** - *

- * Writes a rectangular area of pixels in the destination - * BufferedImage. Calling this method on an image of type - * different from BufferedImage.TYPE_INT_ARGB and - * BufferedImage.TYPE_INT_RGB will unmanage the image.

- * - * @param img the destination image - * @param x the x location at which to start storing pixels - * @param y the y location at which to start storing pixels - * @param w the width of the rectangle of pixels to store - * @param h the height of the rectangle of pixels to store - * @param pixels an array of pixels, stored as integers - * @throws IllegalArgumentException is pixels is non-null and - * of length < w*h - */ - public static void setPixels(BufferedImage img, - int x, int y, int w, int h, int[] pixels) { - if (pixels == null || w == 0 || h == 0) { - return; - } else if (pixels.length < w * h) { - throw new IllegalArgumentException("pixels array must have a length" - + " >= w*h"); - } - - int imageType = img.getType(); - if (imageType == BufferedImage.TYPE_INT_ARGB - || imageType == BufferedImage.TYPE_INT_RGB) { - WritableRaster raster = img.getRaster(); - raster.setDataElements(x, y, w, h, pixels); - } else { - // Unmanages the image - img.setRGB(x, y, w, h, pixels, 0, w); - } - } -} diff --git a/dropShadow/Main.form b/dropShadow/Main.form deleted file mode 100644 index f894d2a..0000000 --- a/dropShadow/Main.form +++ /dev/null @@ -1,96 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/dropShadow/Main.java b/dropShadow/Main.java deleted file mode 100644 index 943656f..0000000 --- a/dropShadow/Main.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package dropShadow; - -/** - * - * @author RAVEN - */ -public class Main extends javax.swing.JFrame { - - /** - * Creates new form Main - */ - public Main() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jPanel1 = new javax.swing.JPanel(); - PanelShadow panelShadow1 = new PanelShadow(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - - jPanel1.setBackground(new java.awt.Color(255, 255, 255)); - - panelShadow1.setBackground(new java.awt.Color(92, 78, 210)); - panelShadow1.setShadowColor(new java.awt.Color(79, 79, 79)); - panelShadow1.setShadowType(ShadowType.BOT_RIGHT); - - javax.swing.GroupLayout panelShadow1Layout = new javax.swing.GroupLayout(panelShadow1); - panelShadow1.setLayout(panelShadow1Layout); - panelShadow1Layout.setHorizontalGroup( - panelShadow1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 500, Short.MAX_VALUE) - ); - panelShadow1Layout.setVerticalGroup( - panelShadow1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 500, Short.MAX_VALUE) - ); - - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGap(93, 93, 93) - .addComponent(panelShadow1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(166, Short.MAX_VALUE)) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGap(54, 54, 54) - .addComponent(panelShadow1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(81, Short.MAX_VALUE)) - ); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGap(0, 0, 0)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - ); - - pack(); - setLocationRelativeTo(null); - }// //GEN-END:initComponents - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the form */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - new Main().setVisible(true); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel jPanel1; - private PanelShadow panelShadow1; - // End of variables declaration//GEN-END:variables -} diff --git a/dropShadow/PanelShadow.java b/dropShadow/PanelShadow.java deleted file mode 100644 index be1c2f3..0000000 --- a/dropShadow/PanelShadow.java +++ /dev/null @@ -1,100 +0,0 @@ -package dropShadow; - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.awt.image.BufferedImage; -import javax.swing.JPanel; - -public class PanelShadow extends JPanel { - - public ShadowType getShadowType() { - return shadowType; - } - - public void setShadowType(ShadowType shadowType) { - this.shadowType = shadowType; - } - - public int getShadowSize() { - return shadowSize; - } - - public void setShadowSize(int shadowSize) { - this.shadowSize = shadowSize; - } - - public float getShadowOpacity() { - return shadowOpacity; - } - - public void setShadowOpacity(float shadowOpacity) { - this.shadowOpacity = shadowOpacity; - } - - public Color getShadowColor() { - return shadowColor; - } - - public void setShadowColor(Color shadowColor) { - this.shadowColor = shadowColor; - } - - private ShadowType shadowType = ShadowType.CENTER; - private int shadowSize = 6; - private float shadowOpacity = 0.5f; - private Color shadowColor = Color.BLACK; - - public PanelShadow() { - setOpaque(false); - } - - @Override - protected void paintComponent(Graphics grphcs) { - createShadow(grphcs); - super.paintComponent(grphcs); - } - - private void createShadow(Graphics grphcs) { - Graphics2D g2 = (Graphics2D) grphcs; - int size = shadowSize * 2; - int x = 0; - int y = 0; - int width = getWidth() - size; - int height = getHeight() - size; - if (shadowType == ShadowType.TOP) { - x = shadowSize; - y = size; - } else if (shadowType == ShadowType.BOT) { - x = shadowSize; - y = 0; - } else if (shadowType == ShadowType.TOP_LEFT) { - x = size; - y = size; - } else if (shadowType == ShadowType.TOP_RIGHT) { - x = 0; - y = size; - } else if (shadowType == ShadowType.BOT_LEFT) { - x = size; - y = 0; - } else if (shadowType == ShadowType.BOT_RIGHT) { - x = 0; - y = 0; - } else { - // Center - x = shadowSize; - y = shadowSize; - } - BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = img.createGraphics(); - g.setColor(getBackground()); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - // g.fillRoundRect(0, 0, width, height, 10, 10); - g.fillOval(0, 0, width, width); - // Create Shadow - ShadowRenderer render = new ShadowRenderer(shadowSize, shadowOpacity, shadowColor); - g2.drawImage(render.createShadow(img), 0, 0, null); - g2.drawImage(img, x, y, null); - } -} diff --git a/dropShadow/ShadowRenderer.java b/dropShadow/ShadowRenderer.java deleted file mode 100644 index d80d2c8..0000000 --- a/dropShadow/ShadowRenderer.java +++ /dev/null @@ -1,185 +0,0 @@ -package dropShadow; - -import java.awt.Color; -import java.awt.image.BufferedImage; - -public class ShadowRenderer { - - // size of the shadow in pixels (defines the fuzziness) - private int size = 5; - - // opacity of the shadow - private float opacity = 0.5f; - - // color of the shadow - private Color color = Color.BLACK; - - public ShadowRenderer() { - this(5, 0.5f, Color.BLACK); - } - - public ShadowRenderer(final int size, final float opacity, final Color color) { - this.size = size; - this.opacity = opacity; - this.color = color; - } - - public Color getColor() { - return color; - } - - public float getOpacity() { - return opacity; - } - - public int getSize() { - return size; - } - - public BufferedImage createShadow(final BufferedImage image) { - // Written by Sesbastien Petrucci - int shadowSize = size * 2; - - int srcWidth = image.getWidth(); - int srcHeight = image.getHeight(); - - int dstWidth = srcWidth + shadowSize; - int dstHeight = srcHeight + shadowSize; - - int left = size; - int right = shadowSize - left; - - int yStop = dstHeight - right; - - int shadowRgb = color.getRGB() & 0x00FFFFFF; - int[] aHistory = new int[shadowSize]; - int historyIdx; - - int aSum; - - BufferedImage dst = new BufferedImage(dstWidth, dstHeight, - BufferedImage.TYPE_INT_ARGB); - - int[] dstBuffer = new int[dstWidth * dstHeight]; - int[] srcBuffer = new int[srcWidth * srcHeight]; - - GraphicsUtilities.getPixels(image, 0, 0, srcWidth, srcHeight, srcBuffer); - - int lastPixelOffset = right * dstWidth; - float hSumDivider = 1.0f / shadowSize; - float vSumDivider = opacity / shadowSize; - - int[] hSumLookup = new int[256 * shadowSize]; - for (int i = 0; i < hSumLookup.length; i++) { - hSumLookup[i] = (int) (i * hSumDivider); - } - - int[] vSumLookup = new int[256 * shadowSize]; - for (int i = 0; i < vSumLookup.length; i++) { - vSumLookup[i] = (int) (i * vSumDivider); - } - - int srcOffset; - - // horizontal pass : extract the alpha mask from the source picture and - // blur it into the destination picture - for (int srcY = 0, dstOffset = left * dstWidth; srcY < srcHeight; srcY++) { - - // first pixels are empty - for (historyIdx = 0; historyIdx < shadowSize;) { - aHistory[historyIdx++] = 0; - } - - aSum = 0; - historyIdx = 0; - srcOffset = srcY * srcWidth; - - // compute the blur average with pixels from the source image - for (int srcX = 0; srcX < srcWidth; srcX++) { - - int a = hSumLookup[aSum]; - dstBuffer[dstOffset++] = a << 24; // store the alpha value only - // the shadow color will be added in the next pass - - aSum -= aHistory[historyIdx]; // substract the oldest pixel from the sum - - // extract the new pixel ... - a = srcBuffer[srcOffset + srcX] >>> 24; - aHistory[historyIdx] = a; // ... and store its value into history - aSum += a; // ... and add its value to the sum - - if (++historyIdx >= shadowSize) { - historyIdx -= shadowSize; - } - } - - // blur the end of the row - no new pixels to grab - for (int i = 0; i < shadowSize; i++) { - - int a = hSumLookup[aSum]; - dstBuffer[dstOffset++] = a << 24; - - // substract the oldest pixel from the sum ... and nothing new to add ! - aSum -= aHistory[historyIdx]; - - if (++historyIdx >= shadowSize) { - historyIdx -= shadowSize; - } - } - } - - // vertical pass - for (int x = 0, bufferOffset = 0; x < dstWidth; x++, bufferOffset = x) { - - aSum = 0; - - // first pixels are empty - for (historyIdx = 0; historyIdx < left;) { - aHistory[historyIdx++] = 0; - } - - // and then they come from the dstBuffer - for (int y = 0; y < right; y++, bufferOffset += dstWidth) { - int a = dstBuffer[bufferOffset] >>> 24; // extract alpha - aHistory[historyIdx++] = a; // store into history - aSum += a; // and add to sum - } - - bufferOffset = x; - historyIdx = 0; - - // compute the blur avera`ge with pixels from the previous pass - for (int y = 0; y < yStop; y++, bufferOffset += dstWidth) { - - int a = vSumLookup[aSum]; - dstBuffer[bufferOffset] = a << 24 | shadowRgb; // store alpha value + shadow color - - aSum -= aHistory[historyIdx]; // substract the oldest pixel from the sum - - a = dstBuffer[bufferOffset + lastPixelOffset] >>> 24; // extract the new pixel ... - aHistory[historyIdx] = a; // ... and store its value into history - aSum += a; // ... and add its value to the sum - - if (++historyIdx >= shadowSize) { - historyIdx -= shadowSize; - } - } - - // blur the end of the column - no pixels to grab anymore - for (int y = yStop; y < dstHeight; y++, bufferOffset += dstWidth) { - - int a = vSumLookup[aSum]; - dstBuffer[bufferOffset] = a << 24 | shadowRgb; - - aSum -= aHistory[historyIdx]; // substract the oldest pixel from the sum - - if (++historyIdx >= shadowSize) { - historyIdx -= shadowSize; - } - } - } - - GraphicsUtilities.setPixels(dst, 0, 0, dstWidth, dstHeight, dstBuffer); - return dst; - } -} diff --git a/dropShadow/ShadowType.java b/dropShadow/ShadowType.java deleted file mode 100644 index 8cdcb76..0000000 --- a/dropShadow/ShadowType.java +++ /dev/null @@ -1,5 +0,0 @@ -package dropShadow; - -public enum ShadowType { - CENTER, TOP_RIGHT, TOP_LEFT, BOT_RIGHT, BOT_LEFT, BOT, TOP -} diff --git a/lib/javafx-swt.jar b/lib/javafx-swt.jar new file mode 100644 index 0000000..4e8c4cf Binary files /dev/null and b/lib/javafx-swt.jar differ diff --git a/lib/javafx.base.jar b/lib/javafx.base.jar new file mode 100644 index 0000000..426f4be Binary files /dev/null and b/lib/javafx.base.jar differ diff --git a/lib/javafx.controls.jar b/lib/javafx.controls.jar new file mode 100644 index 0000000..f7f1c96 Binary files /dev/null and b/lib/javafx.controls.jar differ diff --git a/lib/javafx.fxml.jar b/lib/javafx.fxml.jar new file mode 100644 index 0000000..58bba56 Binary files /dev/null and b/lib/javafx.fxml.jar differ diff --git a/lib/javafx.graphics.jar b/lib/javafx.graphics.jar new file mode 100644 index 0000000..cdd2e46 Binary files /dev/null and b/lib/javafx.graphics.jar differ diff --git a/lib/javafx.media.jar b/lib/javafx.media.jar new file mode 100644 index 0000000..eb196bd Binary files /dev/null and b/lib/javafx.media.jar differ diff --git a/lib/javafx.properties b/lib/javafx.properties new file mode 100644 index 0000000..9577822 --- /dev/null +++ b/lib/javafx.properties @@ -0,0 +1,3 @@ +javafx.version=20.0.1 +javafx.runtime.version=20.0.1+2 +javafx.runtime.build=2 diff --git a/lib/javafx.swing.jar b/lib/javafx.swing.jar new file mode 100644 index 0000000..20501ed Binary files /dev/null and b/lib/javafx.swing.jar differ diff --git a/lib/javafx.web.jar b/lib/javafx.web.jar new file mode 100644 index 0000000..c7c3f49 Binary files /dev/null and b/lib/javafx.web.jar differ diff --git a/lib/libavplugin-54.so b/lib/libavplugin-54.so new file mode 100755 index 0000000..354e77c Binary files /dev/null and b/lib/libavplugin-54.so differ diff --git a/lib/libavplugin-56.so b/lib/libavplugin-56.so new file mode 100755 index 0000000..6f523a1 Binary files /dev/null and b/lib/libavplugin-56.so differ diff --git a/lib/libavplugin-57.so b/lib/libavplugin-57.so new file mode 100755 index 0000000..c954188 Binary files /dev/null and b/lib/libavplugin-57.so differ diff --git a/lib/libavplugin-ffmpeg-56.so b/lib/libavplugin-ffmpeg-56.so new file mode 100755 index 0000000..fa3c9a8 Binary files /dev/null and b/lib/libavplugin-ffmpeg-56.so differ diff --git a/lib/libavplugin-ffmpeg-57.so b/lib/libavplugin-ffmpeg-57.so new file mode 100755 index 0000000..e1b48c2 Binary files /dev/null and b/lib/libavplugin-ffmpeg-57.so differ diff --git a/lib/libavplugin-ffmpeg-58.so b/lib/libavplugin-ffmpeg-58.so new file mode 100755 index 0000000..3b8964b Binary files /dev/null and b/lib/libavplugin-ffmpeg-58.so differ diff --git a/lib/libavplugin-ffmpeg-59.so b/lib/libavplugin-ffmpeg-59.so new file mode 100755 index 0000000..462f746 Binary files /dev/null and b/lib/libavplugin-ffmpeg-59.so differ diff --git a/lib/libdecora_sse.so b/lib/libdecora_sse.so new file mode 100755 index 0000000..ec9f43d Binary files /dev/null and b/lib/libdecora_sse.so differ diff --git a/lib/libfxplugins.so b/lib/libfxplugins.so new file mode 100755 index 0000000..3820856 Binary files /dev/null and b/lib/libfxplugins.so differ diff --git a/lib/libglass.so b/lib/libglass.so new file mode 100755 index 0000000..8589d83 Binary files /dev/null and b/lib/libglass.so differ diff --git a/lib/libglassgtk2.so b/lib/libglassgtk2.so new file mode 100755 index 0000000..6037324 Binary files /dev/null and b/lib/libglassgtk2.so differ diff --git a/lib/libglassgtk3.so b/lib/libglassgtk3.so new file mode 100755 index 0000000..7e427d5 Binary files /dev/null and b/lib/libglassgtk3.so differ diff --git a/lib/libgstreamer-lite.so b/lib/libgstreamer-lite.so new file mode 100755 index 0000000..b5c4d29 Binary files /dev/null and b/lib/libgstreamer-lite.so differ diff --git a/lib/libjavafx_font.so b/lib/libjavafx_font.so new file mode 100755 index 0000000..0d20843 Binary files /dev/null and b/lib/libjavafx_font.so differ diff --git a/lib/libjavafx_font_freetype.so b/lib/libjavafx_font_freetype.so new file mode 100755 index 0000000..8215598 Binary files /dev/null and b/lib/libjavafx_font_freetype.so differ diff --git a/lib/libjavafx_font_pango.so b/lib/libjavafx_font_pango.so new file mode 100755 index 0000000..7eb6b87 Binary files /dev/null and b/lib/libjavafx_font_pango.so differ diff --git a/lib/libjavafx_iio.so b/lib/libjavafx_iio.so new file mode 100755 index 0000000..ae039b9 Binary files /dev/null and b/lib/libjavafx_iio.so differ diff --git a/lib/libjfxmedia.so b/lib/libjfxmedia.so new file mode 100755 index 0000000..ea1d29a Binary files /dev/null and b/lib/libjfxmedia.so differ diff --git a/lib/libjfxwebkit.so b/lib/libjfxwebkit.so new file mode 100755 index 0000000..9f3495a Binary files /dev/null and b/lib/libjfxwebkit.so differ diff --git a/lib/libprism_common.so b/lib/libprism_common.so new file mode 100755 index 0000000..87ea502 Binary files /dev/null and b/lib/libprism_common.so differ diff --git a/lib/libprism_es2.so b/lib/libprism_es2.so new file mode 100755 index 0000000..3220981 Binary files /dev/null and b/lib/libprism_es2.so differ diff --git a/lib/libprism_sw.so b/lib/libprism_sw.so new file mode 100755 index 0000000..bebd11f Binary files /dev/null and b/lib/libprism_sw.so differ diff --git a/src/main/AudioFilePlayer.java b/src/main/AudioFilePlayer.java new file mode 100644 index 0000000..c3b9728 --- /dev/null +++ b/src/main/AudioFilePlayer.java @@ -0,0 +1,96 @@ +package main; +//Java program to play audio files. imports file scanning and various +//methods from the java audio class in order to do so. +import java.io.File; +import java.io.IOException; + +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.LineEvent; +import javax.sound.sampled.LineListener; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + +public class AudioFilePlayer implements LineListener +{ + //indicates whether the playback completes or not + boolean playCompleted; + Clip audioClip; + + public void play(String audioFilePath) + { + File audioFile = new File(audioFilePath); + + try + { + //creates an audioInput object using the file we + //declared earlier + AudioInputStream audioStream = AudioSystem.getAudioInputStream(audioFile); + + //gets the format of the audioStream object + AudioFormat format = audioStream.getFormat(); + + DataLine.Info info = new DataLine.Info(Clip.class, format); + + audioClip = (Clip) AudioSystem.getLine(info); + + audioClip.addLineListener(this); + + audioClip.open(audioStream); + + audioClip.start(); + + while (!playCompleted) + { + // wait for the playback to complete + try + { + Thread.sleep(1000); + } + catch (InterruptedException ex) + { + ex.printStackTrace(); + } + } + audioClip.close(); //stops the audio clip + } + catch (UnsupportedAudioFileException ex) + { + System.out.println("The specified audio file is not supported."); + ex.printStackTrace(); + } + catch (LineUnavailableException ex) + { + System.out.println("Audio line for playing back is unavailable."); + ex.printStackTrace(); + } + catch (IOException ex) + { + System.out.println("Error playing the audio file."); + ex.printStackTrace(); + } + } + + + /** + * Listens to the START and STOP events of the audio line. + */ + @Override + public void update(LineEvent event) + { + LineEvent.Type type = event.getType(); + + if (type == LineEvent.Type.START) + { + System.out.println("Playback started."); + } + else if (type == LineEvent.Type.STOP) + { + playCompleted = true; + System.out.println("Playback completed."); + } + } +} diff --git a/src/main/Driver.java b/src/main/Driver.java new file mode 100644 index 0000000..7b04b2f --- /dev/null +++ b/src/main/Driver.java @@ -0,0 +1,19 @@ +/*Name: + *Date: + *Period: + *Teacher: + *Description: + */ +package main; + + +public class Driver +{ + + public static void main(String[] args) + { + System.out.println("test"); + //new shadowtest(); + } + +} diff --git a/src/main/Gui.java b/src/main/Gui.java new file mode 100644 index 0000000..a8dad5c --- /dev/null +++ b/src/main/Gui.java @@ -0,0 +1,41 @@ +/*Name: + *Date: + *Period: + *Teacher: + *Description: + */ +package main; + +import javax.swing.JButton; +import javax.swing.JFrame; +public class Gui { + public Gui() + { + /* JFrame is a top level container (window) + * where we would be adding our button + */ + JFrame frame=new JFrame(); + + // Creating Button + JButton b=new JButton("Click Me.."); + /* This method specifies the location and size + * of button. In method setBounds(x, y, width, height) + * x,y) are cordinates from the top left + * corner and remaining two arguments are the width + * and height of the button. + */ + b.setBounds(50,50,200, 50); + + //Adding button onto the frame + frame.add(b); + + // Setting Frame size. This is the window size + frame.setSize(600,500); + + frame.setLayout(null); + frame.setVisible(true); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + } +} diff --git a/src/main/KeyDetection.java b/src/main/KeyDetection.java new file mode 100644 index 0000000..7887405 --- /dev/null +++ b/src/main/KeyDetection.java @@ -0,0 +1,27 @@ +/*Name: + *Date: + *Period: + *Teacher: + *Description: + */ +package main; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +public class KeyDetection extends AbstractAction +{ + long timeStart = System.currentTimeMillis(); + private char key; + public KeyDetection(char ch){ + key = ch; + } + + public void actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + int time = (int)((System.currentTimeMillis()-timeStart)); + System.out.println(key + ": " + time); + } + +} diff --git a/src/main/NoteTest.java b/src/main/NoteTest.java new file mode 100644 index 0000000..34d9c8c --- /dev/null +++ b/src/main/NoteTest.java @@ -0,0 +1,35 @@ +/*Name: + *Date: + *Period: + *Teacher: + *Description: + */ +package main; +import java.awt.*; + +public class NoteTest +{ + private boolean failed = false; + private int lane; + private final int NOTESPEED = 1; + private int yPos = SongPlayer.HEIGHT; + + public void gameTick() { + if (!failed) { + if (yPos > 0) { + yPos -= NOTESPEED; + } + else { + failed = true; + } + } + } + + public boolean getFailed() { + return failed; + } + + public int getY() { + return yPos; + } +} diff --git a/src/main/RoundedRectangleTest.java b/src/main/RoundedRectangleTest.java new file mode 100644 index 0000000..e5f40d2 --- /dev/null +++ b/src/main/RoundedRectangleTest.java @@ -0,0 +1,92 @@ +package main; + +import java.awt.*; +import java.awt.event.*; +import java.awt.geom.AffineTransform; +import java.awt.geom.RoundRectangle2D; +//import javafx.scene.effect.DropShadow; + +import javax.swing.*; + +public class RoundedRectangleTest extends JFrame { + public RoundedRectangleTest() { + setTitle("RoundedRectangle Test"); + setSize(350, 275); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + } + public void paint(Graphics g) { + //DropShadowBorder shadow = new DropShadowBorder(); + + Graphics2D g2d = (Graphics2D) g; + g2d.setPaint(Color.DARK_GRAY); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.fillRoundRect(10, 50, 150, 150, 30, 30); // to draw a rounded rectangle. + + /*Graphics2D g2d = (Graphics2D) g; + Color holdColor = g2d.getColor(); + g2d.setColor(Color.black); + AffineTransform holdTransform = g2d.getTransform(); + // want the shadow to be one line width pixel offset + float lineWidth; + if (g2d.getStroke() instanceof BasicStroke) + { + lineWidth = ((BasicStroke) (g2d.getStroke())).getLineWidth(); + } + else + { + lineWidth = 1.0f; + } + //System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth); + //g2d.translate(lineWidth, lineWidth); + g2d.fillRoundRect(10, 50, 150, 150, 30, 30); + //g2d.setColor(holdColor); + //g2d.setTransform(holdTransform); + //g2d.drawRoundRect(10, 50, 150, 150, 30, 30); + */ + + + } + public static void main(String []args) { + new RoundedRectangleTest(); + } + + public static void drawShadowedShape(Shape shape, Graphics2D g2d) + { + Color holdColor = g2d.getColor(); + g2d.setColor(Color.black); + AffineTransform holdTransform = g2d.getTransform(); + // want the shadow to be one line width pixel offset + float lineWidth; + if (g2d.getStroke() instanceof BasicStroke) + { + lineWidth = ((BasicStroke) (g2d.getStroke())).getLineWidth(); + } + else + { + lineWidth = 1.0f; + } + //System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth); + g2d.translate(lineWidth, lineWidth); + g2d.draw(shape); + g2d.setColor(holdColor); + g2d.setTransform(holdTransform); + g2d.draw(shape); + } + + public static void drawShadowedShape2(Shape shape, Graphics2D g2d) { + Color holdColor = g2d.getColor(); + g2d.setColor(Color.black); + AffineTransform holdTransform = g2d.getTransform(); + // want the shadow to be one line width pixel offset + float lineWidth = g2d.getStroke() instanceof BasicStroke ? ((BasicStroke) (g2d.getStroke())).getLineWidth() + : 1.0f; + //System.err.println("DrawingUtilities.drawShadowedShape(): lineWidth = "+lineWidth); + g2d.translate(lineWidth, lineWidth); + g2d.draw(shape); + g2d.setColor(holdColor); + g2d.setTransform(holdTransform); + g2d.draw(shape); + } +} \ No newline at end of file diff --git a/src/main/SongPlayer.java b/src/main/SongPlayer.java new file mode 100644 index 0000000..caf1ab7 --- /dev/null +++ b/src/main/SongPlayer.java @@ -0,0 +1,97 @@ +/*Name: + *Date: + *Period: + *Teacher: + *Description: + */ +package main; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + + +public class SongPlayer +{ + public static final int HEIGHT = 650; + public static final int LENGTH = 400; + + + private final int BLENGTH = LENGTH/6; + private final int BHEIGHT = HEIGHT/20; + JFrame frame = new JFrame("Guitar Hero"); //creates the frame + + + JButton d = new JButton("D"); //creates the four button lanes + JButton f = new JButton("F"); + JButton h = new JButton("H"); + JButton j = new JButton("J"); + + + public void createAndShowGui() { + + d.setBounds(1*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); //makes the button bounds for each button + f.setBounds(2*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); + h.setBounds(3*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); + j.setBounds(4*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); + + + frame.add(d); //adds the buttons to the frame + frame.add(f); + frame.add(h); + frame.add(j); + + frame.setSize(LENGTH, HEIGHT); //sets the size of the frame + frame.setLayout(null); //??? + frame.setVisible(true); //makes the frame visible + + KeyDetection dAction = new KeyDetection('d'); //creates an action for each char + d.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('d'), "dPress"); //Input map and Action map setting + d.getActionMap().put("dPress", dAction); + d.setFocusable(false); //makes it so you can't highlight the button + + KeyDetection fAction = new KeyDetection('f'); + f.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('f'), "fPress"); + f.getActionMap().put("fPress", fAction); + f.setFocusable(false); + + KeyDetection hAction = new KeyDetection('h'); + h.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('h'), "hPress"); + h.getActionMap().put("hPress", hAction); + h.setFocusable(false); + + KeyDetection jAction = new KeyDetection('j'); + j.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('j'), "jPress"); + j.getActionMap().put("jPress", jAction); + j.setFocusable(false); + } + + public void loop() { + JButton note = new JButton(); + JButton test = new JButton(); + test.setBounds(200, 200, 100, 100); + note.setBounds(BLENGTH, 0, BLENGTH, BHEIGHT); + frame.add(note); + frame.add(test); + + NoteTest a = new NoteTest(); + while (!a.getFailed()) { + if (!a.getFailed()) { + a.gameTick(); + note.setBounds(BLENGTH, HEIGHT-a.getY(), BLENGTH, BHEIGHT); //moves the note down every frame + System.out.println(a.getFailed()); + //the computer runs too fast normally, force it to run at a certain fps + try { + Thread.sleep(2); + } catch (InterruptedException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if (a.getFailed()) { + frame.remove(note); //removes the note once its off the screen + } + } + } +} diff --git a/src/main/TButton.java b/src/main/TButton.java new file mode 100644 index 0000000..ab3cfa8 --- /dev/null +++ b/src/main/TButton.java @@ -0,0 +1,30 @@ +package main; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.Color; +import java.awt.Graphics; + +public class TButton extends JButton{ + public TButton(String text) { + super(text); + super.setContentAreaFilled(false); + } + + @Override + protected void paintComponent(Graphics g) { + Color temp = super.getBackground(); + if (getModel().isPressed()) { + g.setColor(temp.darker().darker()); + } else if (getModel().isRollover()) { + g.setColor(temp.darker()); + } else { + g.setColor(temp); + } + g.fillRect(0, 0, getWidth(), getHeight()); + super.paintComponent(g); + super.setBorderPainted(false); + } +} diff --git a/src/main/block.java b/src/main/block.java new file mode 100644 index 0000000..cb04132 --- /dev/null +++ b/src/main/block.java @@ -0,0 +1,85 @@ +package main; + +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.geom.Path2D; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + +// + +public class block { + + public static void main(String[] args) { + new block(); + } + + public block() { + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + /*try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { + ex.printStackTrace(); + } + */ + + JFrame frame = new JFrame("Testing"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.add(new TestPane()); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + + } + }); + } + + public class TestPane extends JPanel { + + private RightEnd rightEnd; + + public TestPane() { + rightEnd = new RightEnd(100, 100, 40); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(100, 100); + } + + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + int x = (getWidth() - 100) / 2; + int y = (getHeight()- 100) / 2; + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.translate(x, y); + g2d.fill(rightEnd); + g2d.dispose(); + } + + + } + + public class RightEnd extends Path2D.Float { + + public RightEnd(float width, float height, float radius) { + moveTo(0, 0); + lineTo(width - radius, 0); + curveTo(width, 0, width, 0, width, radius); + lineTo(width, height - radius); + curveTo(width, height, width, height, width - radius, height); + lineTo(0, height); + closePath(); + } + } +} diff --git a/src/main/jfxTest.java b/src/main/jfxTest.java new file mode 100644 index 0000000..9552946 --- /dev/null +++ b/src/main/jfxTest.java @@ -0,0 +1,35 @@ +package main; + +import javafx.application.Application; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + +public class jfxTest extends Application { + public static void main(String[] args) { + launch(args); + } + + @Override + public void start(Stage primaryStage) { + primaryStage.setTitle("Hello World!"); + Button btn = new Button(); + btn.setText("Say 'Hello World'"); + btn.setOnAction(new EventHandler() { + + @Override + public void handle(ActionEvent event) { + System.out.println("Hello World!"); + } + }); + + StackPane root = new StackPane(); + root.getChildren().add(btn); + primaryStage.setScene(new Scene(root, 300, 250)); + primaryStage.show(); + + } +} \ No newline at end of file diff --git a/src/main/shadowtest.java b/src/main/shadowtest.java new file mode 100644 index 0000000..e24ae36 --- /dev/null +++ b/src/main/shadowtest.java @@ -0,0 +1,40 @@ +package main; +import javafx.scene.effect.DropShadow; +import javafx.scene.paint.Color; +import javafx.scene.shape.Circle; +import javafx.scene.text.Font; +import javafx.scene.text.FontWeight; +import javafx.scene.text.Text; + +public class shadowtest +{ + public shadowtest() + { + DropShadow dropShadow = new DropShadow(); + dropShadow.setRadius(5.0); + dropShadow.setOffsetX(3.0); + dropShadow.setOffsetY(3.0); + dropShadow.setColor(Color.color(0.4, 0.5, 0.5)); + + Text text = new Text(); + text.setEffect(dropShadow); + text.setCache(true); + text.setX(10.0); + text.setY(70.0); + text.setFill(Color.web("0x3b596d")); + text.setText("JavaFX drop shadow..."); + text.setFont(Font.font(null, FontWeight.BOLD, 40)); + + DropShadow dropShadow2 = new DropShadow(); + dropShadow2.setOffsetX(6.0); + dropShadow2.setOffsetY(4.0); + + Circle circle = new Circle(); + circle.setEffect(dropShadow2); + circle.setCenterX(50.0); + circle.setCenterY(125.0); + circle.setRadius(30.0); + circle.setFill(Color.STEELBLUE); + circle.setCache(true); + } +} \ No newline at end of file -- cgit v1.2.3