diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2023-05-06 21:58:36 -0400 | 
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2023-05-06 21:58:36 -0400 | 
| commit | e5873eef980a42e56355de1c8ffc8fe1a0aeedac (patch) | |
| tree | a65b5f67f3850915de32e1cb39fc600ed98ee27c | |
| parent | 372d97fee538f86c8333fbbde43cf51484b8ac67 (diff) | |
| download | NPEhero-e5873eef980a42e56355de1c8ffc8fe1a0aeedac.tar.gz NPEhero-e5873eef980a42e56355de1c8ffc8fe1a0aeedac.tar.bz2 NPEhero-e5873eef980a42e56355de1c8ffc8fe1a0aeedac.zip | |
Deleted old classes and added Block class
| -rw-r--r-- | .vscode/settings.json | 3 | ||||
| -rw-r--r-- | bin/main/application.css | 0 | ||||
| -rw-r--r-- | src/main/Block.java | 27 | ||||
| -rw-r--r-- | src/main/Driver.java | 1 | ||||
| -rw-r--r-- | src/main/Gui.java | 41 | ||||
| -rw-r--r-- | src/main/RoundedRectangleTest.java | 92 | ||||
| -rw-r--r-- | src/main/TButton.java | 30 | ||||
| -rw-r--r-- | src/main/application.css | 0 | ||||
| -rw-r--r-- | src/main/block.java | 85 | ||||
| -rw-r--r-- | src/main/jfxTest.java | 20 | ||||
| -rw-r--r-- | src/main/shadowtest.java | 40 | 
11 files changed, 46 insertions, 293 deletions
| diff --git a/.vscode/settings.json b/.vscode/settings.json index c9eadff..078509d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,6 @@      "java.project.outputPath": "bin",      "java.project.referencedLibraries": [          "lib/**/*.jar" -    ] +    ], +    "java.debug.settings.onBuildFailureProceed": true  }
\ No newline at end of file diff --git a/bin/main/application.css b/bin/main/application.css new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/bin/main/application.css diff --git a/src/main/Block.java b/src/main/Block.java new file mode 100644 index 0000000..8f8267f --- /dev/null +++ b/src/main/Block.java @@ -0,0 +1,27 @@ +//glowing block of color c (jfx node) + +package main; + +import javafx.scene.effect.BlurType; +import javafx.scene.effect.DropShadow; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; + +public class Block extends Rectangle +{ +    public Block(Color c) +    { +        super(); +        DropShadow dropShadow = new DropShadow(); +        dropShadow.setRadius(200.0); +        dropShadow.setColor(c); +        dropShadow.setBlurType(BlurType.GAUSSIAN); +        +        super.setFill(c); +        super.setWidth(200); +        super.setHeight(100); +        super.setArcHeight(25); +        super.setArcWidth(25); +        super.setEffect(dropShadow); +    } +}
\ No newline at end of file diff --git a/src/main/Driver.java b/src/main/Driver.java index 7b04b2f..628644f 100644 --- a/src/main/Driver.java +++ b/src/main/Driver.java @@ -13,7 +13,6 @@ 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 deleted file mode 100644 index a8dad5c..0000000 --- a/src/main/Gui.java +++ /dev/null @@ -1,41 +0,0 @@ -/*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/RoundedRectangleTest.java b/src/main/RoundedRectangleTest.java deleted file mode 100644 index e5f40d2..0000000 --- a/src/main/RoundedRectangleTest.java +++ /dev/null @@ -1,92 +0,0 @@ -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/TButton.java b/src/main/TButton.java deleted file mode 100644 index ab3cfa8..0000000 --- a/src/main/TButton.java +++ /dev/null @@ -1,30 +0,0 @@ -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/application.css b/src/main/application.css new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/main/application.css diff --git a/src/main/block.java b/src/main/block.java deleted file mode 100644 index cb04132..0000000 --- a/src/main/block.java +++ /dev/null @@ -1,85 +0,0 @@ -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 index 9552946..6cc7f93 100644 --- a/src/main/jfxTest.java +++ b/src/main/jfxTest.java @@ -5,7 +5,15 @@ import javafx.event.ActionEvent;  import javafx.event.EventHandler;  import javafx.scene.Scene;  import javafx.scene.control.Button; +import javafx.scene.effect.BlurType; +import javafx.scene.effect.DropShadow; +import javafx.scene.layout.GridPane;  import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Font; +import javafx.scene.text.FontWeight; +import javafx.scene.text.Text;  import javafx.stage.Stage;  public class jfxTest extends Application { @@ -15,7 +23,7 @@ public class jfxTest extends Application {      @Override      public void start(Stage primaryStage) { -        primaryStage.setTitle("Hello World!"); +        primaryStage.setTitle("Title");          Button btn = new Button();          btn.setText("Say 'Hello World'");          btn.setOnAction(new EventHandler<ActionEvent>() { @@ -25,9 +33,15 @@ public class jfxTest extends Application {                  System.out.println("Hello World!");              }          }); + +        Block rect = new Block(Color.RED); +         + -        StackPane root = new StackPane(); -        root.getChildren().add(btn); +        GridPane root = new GridPane(); +        root.gridLinesVisibleProperty(); +        root.add(rect,1,0); +        root.add(btn,0,1);          primaryStage.setScene(new Scene(root, 300, 250));          primaryStage.show(); diff --git a/src/main/shadowtest.java b/src/main/shadowtest.java deleted file mode 100644 index e24ae36..0000000 --- a/src/main/shadowtest.java +++ /dev/null @@ -1,40 +0,0 @@ -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 | 
