u08
This commit is contained in:
parent
5855cb3f4d
commit
4c3398e363
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="/home/stud/p8q-yhw-u1/Downloads/DrawingPanel.jar"/>
|
||||
<classpathentry kind="lib" path="/home/stud/p8q-yhw-u1/Downloads/libloc.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
/bin/
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>u08</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,14 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=17
|
||||
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=17
|
|
@ -0,0 +1,83 @@
|
|||
package de.hsh.prog.klasseline;
|
||||
|
||||
import java.awt.Graphics;
|
||||
|
||||
|
||||
/**
|
||||
* Linie, bestehend aus Start- und Endpunkt
|
||||
* @author p8q-yhw-u1
|
||||
*/
|
||||
public class Line {
|
||||
private Loc p1;
|
||||
private Loc p2;
|
||||
|
||||
/**
|
||||
* Erstellt ein Line Objekt aus Anfangs- und Endkoordinaten
|
||||
* @param x1 x von p1
|
||||
* @param y1 y von p1
|
||||
* @param x2 x von p2
|
||||
* @param y2 y von p2
|
||||
*/
|
||||
public Line(int x1, int y1, int x2, int y2) {
|
||||
this.p1 = new Loc(x1, y1);
|
||||
this.p2 = new Loc(x2, y2);
|
||||
}
|
||||
/**
|
||||
* Erstellt ein Line Objekt aus Anfangs- und Endpunkt
|
||||
* @param p1 Startpunkt
|
||||
* @param p2 Endpunkt
|
||||
*/
|
||||
public Line(Loc p1, Loc p2) {
|
||||
this(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy Konstruktor für ein Objekt der Line Klasse
|
||||
* @param l das zu kopierende Line Objekt
|
||||
* @param deep Tiefe (true) oder flache (false) Kopie
|
||||
*/
|
||||
public Line(Line l, boolean deep) {
|
||||
if (deep) {
|
||||
this.p1 = new Loc(l.getP1());
|
||||
this.p2 = new Loc(l.getP2());
|
||||
} else {
|
||||
this.p1 = l.getP1();
|
||||
this.p2 = l.getP2();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Startpunkt
|
||||
*/
|
||||
public Loc getP1() {
|
||||
return p1;
|
||||
}
|
||||
/**
|
||||
* @return Endpunkt
|
||||
*/
|
||||
public Loc getP2() {
|
||||
return p2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt das Line Objekt als String aus
|
||||
*/
|
||||
public String toString() {
|
||||
return "[" + p1 + ", " + p2 + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Länge der Linie
|
||||
*/
|
||||
public double getLength() {
|
||||
return p1.distance(p2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeichnet die Linie
|
||||
* @param g Die Graphics die zum Zeichnen der Linie genutzt werden soll
|
||||
*/
|
||||
public void draw(Graphics g) {
|
||||
g.drawLine(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue