diff --git a/.idea/compiler.xml b/.idea/compiler.xml index c94edeaf9a116855914ef8c1e6599a5784750d89..0a6e50149b66f4c7739e673c931ea5d40ef24e1c 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,5 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> + <component name="CompilerConfiguration"> + <annotationProcessing> + <profile name="Maven default annotation processors profile" enabled="true"> + <sourceOutputDir name="target/generated-sources/annotations" /> + <sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> + <outputRelativeToContentRoot value="true" /> + </profile> + </annotationProcessing> + <bytecodeTargetLevel> + <module name="Aufgabe4Tests" target="15" /> + </bytecodeTargetLevel> + </component> <component name="JavacSettings"> <option name="ADDITIONAL_OPTIONS_OVERRIDE"> <module name="inf3_git" options="--add-modules java.base" /> diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000000000000000000000000000000000000..712ab9d985c20018a0c97b93d2148ac1ffe588a5 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="RemoteRepositoriesConfiguration"> + <remote-repository> + <option name="id" value="central" /> + <option name="name" value="Central Repository" /> + <option name="url" value="https://repo.maven.apache.org/maven2" /> + </remote-repository> + <remote-repository> + <option name="id" value="central" /> + <option name="name" value="Maven Central repository" /> + <option name="url" value="https://repo1.maven.org/maven2" /> + </remote-repository> + <remote-repository> + <option name="id" value="jboss.community" /> + <option name="name" value="JBoss Community repository" /> + <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> + </remote-repository> + </component> +</project> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index d72bc4ca88d59c86b5ca51209deed6c339d4c705..1700c77fc6e767cbe5727a663e192016b616193d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> - <component name="ProjectRootManager" version="2" project-jdk-name="15" project-jdk-type="JavaSDK"> + <component name="ExternalStorageConfigurationManager" enabled="true" /> + <component name="ProjectRootManager" version="2" languageLevel="JDK_15" default="true" project-jdk-name="15" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/out" /> </component> </project> \ No newline at end of file diff --git a/Aufgabe4/Plotter.java b/Aufgabe4/Plotter.java index 6e61b22b00238e7ea168f1894eb7c7dbbda73dfa..9737b0d6c421c358ca31e8418ed10eb056916e98 100644 --- a/Aufgabe4/Plotter.java +++ b/Aufgabe4/Plotter.java @@ -1,11 +1,9 @@ import javax.swing.SwingUtilities; import javax.swing.JFrame; import javax.swing.JPanel; -import javax.swing.BorderFactory; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseAdapter; -import java.awt.geom.Line2D; import java.util.Arrays; public class Plotter { @@ -30,6 +28,7 @@ public class Plotter { JFrame f = new JFrame("Function Plotter"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new PlotterPanel(valuesToDraw)); + f.setLocationRelativeTo(null); f.pack(); f.setVisible(true); @@ -38,20 +37,15 @@ public class Plotter { class PlotterPanel extends JPanel { + // int array placeholders that get written into the values that should be displayed - int[] test = new int[]{-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, - -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; - int[] test2 = new int[]{-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, - -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; + int[] xCords = new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + int[] yCords = new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - - - - final int ZERO_POINT_X = 300; - final int ZERO_POINT_Y = 400; + // offset values to have coordinates appear in the middle of a 800x600 window + final int ZERO_POINT_Y = 300; + final int ZERO_POINT_X = 400; ValuesToDraw valuesToDraw; @@ -63,11 +57,10 @@ class PlotterPanel extends JPanel { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { - System.out.println("maus gedrückt"); - int[] xCordsWithOffset = new int[41]; int[] yCordsWithOffset = new int[41]; + int[] xCordsWithOffset = new int[41]; int i = 0; @@ -76,11 +69,11 @@ class PlotterPanel extends JPanel { for(int cord : xCords) { - xCordsWithOffset[i] = (ZERO_POINT_X + (cord * -1 * 10)); + yCordsWithOffset[i] = (ZERO_POINT_Y + (cord * -1 * 10)); i++; } - System.out.println(Arrays.toString(xCordsWithOffset)); + System.out.println(Arrays.toString(yCordsWithOffset)); int j = 0; @@ -88,15 +81,16 @@ class PlotterPanel extends JPanel { for(int cord : yCords) { System.out.print("cords=" + cord); - yCordsWithOffset[j] = ZERO_POINT_Y + (cord * 10); + xCordsWithOffset[j] = ZERO_POINT_X + (cord * 10); j++; } - System.out.println(Arrays.toString(yCordsWithOffset)); + System.out.println(Arrays.toString(xCordsWithOffset)); - test2 = xCordsWithOffset; - test = yCordsWithOffset; + PlotterPanel.this.yCords = yCordsWithOffset; + PlotterPanel.this.xCords = xCordsWithOffset; + @@ -117,32 +111,38 @@ class PlotterPanel extends JPanel { super.paintComponent(g); - g.drawLine(400, 0, 400, 600); - g.drawLine(0, 300, 800, 300); + //paints coordinate system + // draw x and y axis + g.drawLine(400, 50, 400, 550); + g.drawLine(150, 300, 650, 300); //x=0, y=20 - g.drawLine(375, 100, 425, 100); + g.drawLine(395, 100, 405, 100); //x=0, y=-20 - g.drawLine(375, 500, 425, 500); + g.drawLine(395, 500, 405, 500); //x=-20, y=0 - g.drawLine(200,275 , 200, 325); + g.drawLine(200,295 , 200, 305); //x=20, y=0 - g.drawLine(600,275 , 600, 325); + g.drawLine(600,295 , 600, 305); + + + //paints the lines that are in xCords and yCords - drawPoints(g); + drawLine(g); } - private void drawPoints(Graphics g){ + private void drawLine(Graphics g){ Graphics2D g2d = (Graphics2D) g; + g2d.setColor(Color.RED); - g2d.drawPolyline(test, test2, 41); + g2d.drawPolyline(xCords, yCords, 41); } diff --git a/out/production/inf3_git/main.class b/out/production/inf3_git/main.class index 3623c2b8f2866a0612ae6e474e1cc569363d8d5a..a4e8897c9a16d33fbd487695fe33cf6e329876c6 100644 Binary files a/out/production/inf3_git/main.class and b/out/production/inf3_git/main.class differ