mirror of
https://github.com/13hannes11/archive.git
synced 2024-09-03 21:50:58 +02:00
added all past projects
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package geometrischefiguren;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.GeneralPath;
|
||||
|
||||
public class Dreieck extends Strecke {
|
||||
|
||||
protected Strecke _b, _a;
|
||||
|
||||
public Dreieck(Punkt a, Punkt b, Punkt c) {
|
||||
super(a, b);
|
||||
this._a = new Strecke(b, c);
|
||||
this._b = new Strecke(c, a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void zeichne(Graphics g) {
|
||||
// super.zeichne(g);
|
||||
// _a.zeichne(g);
|
||||
// _b.zeichne(g);
|
||||
// draw GeneralPath (polygon)
|
||||
|
||||
int x1Points[] = {this.x, this._a.x, this._b.x};
|
||||
int y1Points[] = {this.y, this._a.y, this._b.y};
|
||||
GeneralPath polygon =
|
||||
new GeneralPath(GeneralPath.WIND_EVEN_ODD,
|
||||
x1Points.length);
|
||||
polygon.moveTo(x1Points[0], y1Points[0]);
|
||||
|
||||
for (int index = 1; index < x1Points.length; index++) {
|
||||
polygon.lineTo(x1Points[index], y1Points[index]);
|
||||
};
|
||||
|
||||
polygon.closePath();
|
||||
((Graphics2D)g).draw(polygon);
|
||||
//((Graphics2D)g).fill(polygon);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Form>
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package geometrischefiguren;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Hannes
|
||||
*/
|
||||
public class GeometrischeFigurenOberfläche extends javax.swing.JFrame {
|
||||
ArrayList<Punkt> p = new ArrayList();
|
||||
|
||||
/**
|
||||
* Creates new form GeometrischeFigurenOberfläche
|
||||
*/
|
||||
public GeometrischeFigurenOberfläche() {
|
||||
initComponents();
|
||||
p.add(new Kreis(new Punkt(150, 150), 50));
|
||||
p.add(new Punkt(10, 100));
|
||||
p.add(new Strecke(10, 20, new Punkt(100, 100)));
|
||||
p.add(new Dreieck(new Punkt(100,200), new Punkt(200, 300), new Punkt(10, 10)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
for (Punkt m : p) {
|
||||
m.zeichne(g);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* 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(GeometrischeFigurenOberfläche.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(GeometrischeFigurenOberfläche.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(GeometrischeFigurenOberfläche.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(GeometrischeFigurenOberfläche.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the form */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new GeometrischeFigurenOberfläche().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
28
Java/GeometrischeFiguren/src/geometrischefiguren/Kreis.java
Normal file
28
Java/GeometrischeFiguren/src/geometrischefiguren/Kreis.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package geometrischefiguren;
|
||||
|
||||
import java.awt.Graphics;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Hannes
|
||||
*/
|
||||
public class Kreis extends Punkt {
|
||||
|
||||
int r;
|
||||
|
||||
public Kreis(Punkt p, int radius) {
|
||||
super(p.x, p.y);
|
||||
r = radius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void zeichne(Graphics g) {
|
||||
super.zeichne(g);
|
||||
g.drawOval(x - r, y - r, r*2, r*2);
|
||||
|
||||
}
|
||||
}
|
||||
33
Java/GeometrischeFiguren/src/geometrischefiguren/Punkt.java
Normal file
33
Java/GeometrischeFiguren/src/geometrischefiguren/Punkt.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package geometrischefiguren;
|
||||
|
||||
import java.awt.Graphics;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Hannes
|
||||
*/
|
||||
public class Punkt {
|
||||
protected int x, y; //Koordinaten in der Zeichnung
|
||||
|
||||
public Punkt(int posX, int posY)
|
||||
{
|
||||
this.x = posX;
|
||||
this.y = posY;
|
||||
}
|
||||
|
||||
public void zeichne(Graphics g)
|
||||
{
|
||||
g.drawRect(x, y, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "(" + x + "," + y + ")";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package geometrischefiguren;
|
||||
|
||||
import java.awt.Graphics;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Hannes
|
||||
*/
|
||||
public class Strecke extends Punkt {
|
||||
protected Punkt _ende;
|
||||
protected double länge;
|
||||
|
||||
public Strecke(Punkt anfang, Punkt ende)
|
||||
{
|
||||
super(anfang.x, anfang.y); //Super ruft den Konstruktor der Elternklasse Punkt auf
|
||||
//ererbte eigenschaft hat somit die Bedeutung des Punktes von dem aus gezeichnet wird
|
||||
this._ende = ende;
|
||||
setLänge();
|
||||
}
|
||||
public Strecke(int x, int y, Punkt ende)
|
||||
{
|
||||
super(x,y);
|
||||
this._ende = ende;
|
||||
setLänge();
|
||||
}
|
||||
@Override
|
||||
public void zeichne(Graphics g)
|
||||
{
|
||||
g.drawLine(x, y, _ende.x, _ende.y);
|
||||
}
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Strecke(" + super.toString() + " bis " + _ende + "; länge( " + länge + " ))";
|
||||
}
|
||||
private void setLänge()
|
||||
{
|
||||
int deltaX = x - _ende.x;
|
||||
int deltaY = y - _ende.y;
|
||||
länge = Math.sqrt(deltaX*deltaX + deltaY*deltaY); // sqrt(a^2 + b^2)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user