From 6ddaa62eba630a2bc91c064e5f2e4a48cd2057f2 Mon Sep 17 00:00:00 2001 From: Maxamax1 <74760408+Maxamax1@users.noreply.github.com> Date: Wed, 28 Sep 2022 09:51:27 +0200 Subject: [PATCH] Add files via upload --- src/Datenbank.java | 1054 ++++++++++++----------- src/Dreieck.java | 1781 +++++++++++++++++++++------------------ src/Figur.java | 10 +- src/Geometrie.db | Bin 20480 -> 28672 bytes src/Kreis.java | 143 ++-- src/Main_Geometrie.java | 1597 ++++++++++++++++++----------------- src/Quadrat.java | 129 +-- src/Rechteck.java | 692 +++++++-------- 8 files changed, 2838 insertions(+), 2568 deletions(-) diff --git a/src/Datenbank.java b/src/Datenbank.java index 05ba187..3022b6c 100644 --- a/src/Datenbank.java +++ b/src/Datenbank.java @@ -1,4 +1,8 @@ +import java.io.IOException; +import java.nio.file.FileAlreadyExistsException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; @@ -8,10 +12,8 @@ import java.util.ArrayList; import javax.swing.table.DefaultTableModel; - - public class Datenbank { - //Variables + // Variables private static Connection myCon; private static PreparedStatement myPrepStmnt; private static ResultSet myRS; @@ -19,51 +21,56 @@ public class Datenbank { private static String user; private static String pwd; private static String type; - - - + /** - * test for Database Connection and Save the Login data + * test for Database Connection and Save the Login data + * * @param url * @param user * @param pwd * @return */ - + public static boolean testDB(String url, String user, String pwd, String type) { boolean ret = false; - - if (type.equals("MySQL") ) { - try { - - myCon = DriverManager.getConnection(url, user, pwd); - ret = true; - Datenbank.url = url; - Datenbank.user = user; - Datenbank.pwd = pwd; - Datenbank.type = type; - myCon.close(); - myCon = null; - - } catch (SQLException e) { - ret = false; - e.printStackTrace(); - } finally { - Datenbank.doFinally(); - } - - + + if (type.equals("MySQL")) { + try { + + myCon = DriverManager.getConnection(url, user, pwd); + ret = true; + Datenbank.url = url; + Datenbank.user = user; + Datenbank.pwd = pwd; + Datenbank.type = type; + myCon.close(); + myCon = null; + + } catch (SQLException e) { + ret = false; + e.printStackTrace(); + } finally { + Datenbank.doFinally(); + } + } else if (type.equals("SQLite")) { try { - url = "jdbc:sqlite::resource:Geometrie.db"; + try { + Files.copy(Main_Geometrie.class.getResourceAsStream("Geometrie.db"), Paths.get("Geometrie.db")); + }catch (FileAlreadyExistsException e) { + + }catch (IOException e) { + e.printStackTrace(); + } + url = "jdbc:sqlite:Geometrie.db"; myCon = DriverManager.getConnection(url); ret = true; Datenbank.url = url; Datenbank.type = type; - + myCon.close(); myCon = null; - + } catch (SQLException e) { ret = false; e.printStackTrace(); @@ -74,522 +81,585 @@ public static boolean testDB(String url, String user, String pwd, String type) { return ret; } - -@SuppressWarnings("serial") -public static DefaultTableModel getall(String figur, DefaultTableModel model) { - switch (figur) { - case "Rechteck": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); - + @SuppressWarnings("serial") + public static DefaultTableModel getall(String figur, DefaultTableModel model) { + switch (figur) { + case "Rechteck": + try { + String data[][] = null; + String columns[] = { "ID", "Seite A", "Seite B", "Diagonale", "Fl�che", "Umfang", "Alpha", "Beta", + "Gamma", "Delta" }; + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); + myPrepStmnt = myCon.prepareStatement("SELECT * FROM rechteck", ResultSet.TYPE_SCROLL_SENSITIVE, + ResultSet.CONCUR_UPDATABLE); + myRS = myPrepStmnt.executeQuery(); + myRS.last(); + data = new String[myRS.getRow()][10]; + myRS.first(); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); + myPrepStmnt = myCon.prepareStatement("SELECT * FROM rechteck", ResultSet.TYPE_FORWARD_ONLY, + ResultSet.CONCUR_READ_ONLY); + myRS = myPrepStmnt.executeQuery(); + int row = 0; + myRS.next(); + do { + row++; + }while (myRS.next()); + data = new String[row][10]; + myRS = null; + myRS = myPrepStmnt.executeQuery(); + } - myPrepStmnt = myCon.prepareStatement("SELECT * FROM rechteck", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); - myRS = myPrepStmnt.executeQuery(); - myRS.last(); - String columns[] = { "ID", "Seite A", "Seite B", "Diagonale" , "Fläche", "Umfang", "Alpha", "Beta", "Gamma", "Delta" }; - String data[][] = new String[myRS.getRow()][10]; - - int i = 0; - myRS.first(); - do { - int id = myRS.getInt("rechteckID"); - Double sidea = myRS.getDouble("Sidea"); - Double sideb = myRS.getDouble("Sideb"); - Double diag = myRS.getDouble("diag"); - Double area = myRS.getDouble("area"); - Double umfang = myRS.getDouble("Umfang"); - Double alpha = myRS.getDouble("alpha"); - Double beta = myRS.getDouble("beta"); - Double gamma = myRS.getDouble("gamma"); - Double delta = myRS.getDouble("delta"); - data[i][0] = id + ""; - data[i][1] = sidea + ""; - data[i][2] = sideb + ""; - data[i][3] = diag + ""; - data[i][4] = area + ""; - data[i][5] = umfang + ""; - data[i][6] = alpha + ""; - data[i][7] = beta + ""; - data[i][8] = gamma + ""; - data[i][9] = delta + ""; - i++; - } while (myRS.next()); - model = new DefaultTableModel(data, columns) { - @Override - public boolean isCellEditable(int row, int column) { - //all cells false - return false; - } - }; - - } catch(SQLException e) { - e.printStackTrace(); - } - break; - case "Dreieck": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); + + + int i = 0; + myRS.next(); + do { + int id = myRS.getInt("rechteckID"); + Double sidea = myRS.getDouble("Sidea"); + Double sideb = myRS.getDouble("Sideb"); + Double diag = myRS.getDouble("diag"); + Double area = myRS.getDouble("area"); + Double umfang = myRS.getDouble("Umfang"); + Double alpha = myRS.getDouble("alpha"); + Double beta = myRS.getDouble("beta"); + Double gamma = myRS.getDouble("gamma"); + Double delta = myRS.getDouble("delta"); + data[i][0] = id + ""; + data[i][1] = sidea + ""; + data[i][2] = sideb + ""; + data[i][3] = diag + ""; + data[i][4] = area + ""; + data[i][5] = umfang + ""; + data[i][6] = alpha + ""; + data[i][7] = beta + ""; + data[i][8] = gamma + ""; + data[i][9] = delta + ""; + i++; + } while (myRS.next()); + model = new DefaultTableModel(data, columns) { + @Override + public boolean isCellEditable(int row, int column) { + // all cells false + return false; + } + }; + + } catch (SQLException e) { + e.printStackTrace(); + } + break; + case "Dreieck": + try { + String data[][] = null; + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); + myPrepStmnt = myCon.prepareStatement("SELECT * FROM dreieck", ResultSet.TYPE_SCROLL_SENSITIVE, + ResultSet.CONCUR_UPDATABLE); + myRS = myPrepStmnt.executeQuery(); + myRS.last(); + data = new String[myRS.getRow()][14]; + myRS.first(); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); + myPrepStmnt = myCon.prepareStatement("SELECT * FROM dreieck", ResultSet.TYPE_FORWARD_ONLY, + ResultSet.CONCUR_READ_ONLY); + myRS = myPrepStmnt.executeQuery(); + int row = 0; + myRS.next(); + do { + row++; + }while (myRS.next()); + data = new String[row][14]; + myRS = null; + myRS = myPrepStmnt.executeQuery(); + } - myPrepStmnt = myCon.prepareStatement("SELECT * FROM dreieck", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); - myRS = myPrepStmnt.executeQuery(); - myRS.last(); - - //database = null; - System.out.println(myRS.getRow()); - String columns[] = { "ID", "Seite A", "Seite B", "Seite C" , "Alpha", "Beta", "Gamma", "Höhe A", "Höhe B", "Höhe C", "Fläche", "Umfang", "Inradius", "Umradius"}; - String data[][] = new String[myRS.getRow()][14]; - - int i = 0; - myRS.first(); - do { - int id = myRS.getInt("DreieckID"); - Double sidea = myRS.getDouble("sidea"); - Double sideb = myRS.getDouble("sideb"); - Double sidec = myRS.getDouble("sidec"); - Double alpha = myRS.getDouble("alpha"); - Double beta = myRS.getDouble("beta"); - Double gamma = myRS.getDouble("gamma"); - Double ha = myRS.getDouble("ha"); - Double hb = myRS.getDouble("hb"); - Double hc = myRS.getDouble("hc"); - Double area = myRS.getDouble("flaeche"); - Double umfang = myRS.getDouble("Umfang"); - Double inradius = myRS.getDouble("inradius"); - Double umradius = myRS.getDouble("umradius"); - - data[i][0] = id + ""; - data[i][1] = sidea + ""; - data[i][2] = sideb + ""; - data[i][3] = sidec + ""; - data[i][4] = alpha + ""; - data[i][5] = beta + ""; - data[i][6] = gamma + ""; - data[i][7] = ha + ""; - data[i][8] = hb + ""; - data[i][9] = hc + ""; - data[i][10] = area + ""; - data[i][11] = umfang + ""; - data[i][12] = inradius + ""; - data[i][13] = umradius + ""; - i++; - } while (myRS.next()); - model = new DefaultTableModel(data, columns) { - @Override - public boolean isCellEditable(int row, int column) { - //all cells false - return false; - } - }; - - - } catch(SQLException e) { - e.printStackTrace(); - } - break; - case "Kreis": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); + + // database = null; + //System.out.println(myRS.getRow()); + String columns[] = { "ID", "Seite A", "Seite B", "Seite C", "Alpha", "Beta", "Gamma", "Höhe A", + "Höhe B", "Höhe C", "Fläche", "Umfang", "Inradius", "Umradius" }; + + + int i = 0; + myRS.next(); + do { + int id = myRS.getInt("DreieckID"); + Double sidea = myRS.getDouble("sidea"); + Double sideb = myRS.getDouble("sideb"); + Double sidec = myRS.getDouble("sidec"); + Double alpha = myRS.getDouble("alpha"); + Double beta = myRS.getDouble("beta"); + Double gamma = myRS.getDouble("gamma"); + Double ha = myRS.getDouble("ha"); + Double hb = myRS.getDouble("hb"); + Double hc = myRS.getDouble("hc"); + Double area = myRS.getDouble("flaeche"); + Double umfang = myRS.getDouble("Umfang"); + Double inradius = myRS.getDouble("inradius"); + Double umradius = myRS.getDouble("umradius"); + + data[i][0] = id + ""; + data[i][1] = sidea + ""; + data[i][2] = sideb + ""; + data[i][3] = sidec + ""; + data[i][4] = alpha + ""; + data[i][5] = beta + ""; + data[i][6] = gamma + ""; + data[i][7] = ha + ""; + data[i][8] = hb + ""; + data[i][9] = hc + ""; + data[i][10] = area + ""; + data[i][11] = umfang + ""; + data[i][12] = inradius + ""; + data[i][13] = umradius + ""; + i++; + } while (myRS.next()); + model = new DefaultTableModel(data, columns) { + @Override + public boolean isCellEditable(int row, int column) { + // all cells false + return false; + } + }; + + } catch (SQLException e) { + e.printStackTrace(); + } + break; + case "Kreis": + try { + String data[][] = null; + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); + myPrepStmnt = myCon.prepareStatement("SELECT * FROM kreis", ResultSet.TYPE_SCROLL_SENSITIVE, + ResultSet.CONCUR_UPDATABLE); + myRS = myPrepStmnt.executeQuery(); + myRS.last(); + data = new String[myRS.getRow()][5]; + myRS.first(); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); + myPrepStmnt = myCon.prepareStatement("SELECT * FROM kreis", ResultSet.TYPE_FORWARD_ONLY, + ResultSet.CONCUR_READ_ONLY); + myRS = myPrepStmnt.executeQuery(); + int row = 0; + myRS.next(); + do { + row++; + }while (myRS.next()); + data = new String[row][5]; + myRS = null; + myRS = myPrepStmnt.executeQuery(); + } - myPrepStmnt = myCon.prepareStatement("SELECT * FROM kreis", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); - myRS = myPrepStmnt.executeQuery(); - myRS.last(); - String columns[] = { "KreisID", "Durchmesser", "Umfang", "Radius" , "Fläche"}; - String data[][] = new String[myRS.getRow()][10]; - - int i = 0; - myRS.first(); - do { - int id = myRS.getInt("KreisID"); - Double d = myRS.getDouble("d"); - Double U = myRS.getDouble("U"); - Double r = myRS.getDouble("r"); - Double A = myRS.getDouble("A"); - data[i][0] = id + ""; - data[i][1] = d + ""; - data[i][2] = U + ""; - data[i][3] = r + ""; - data[i][4] = A + ""; - i++; - } while (myRS.next()); - model = new DefaultTableModel(data, columns) { - @Override - public boolean isCellEditable(int row, int column) { - //all cells false - return false; - } - }; - - } catch(SQLException e) { - e.printStackTrace(); - } - break; - case "Quadrat": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); - + String columns[] = { "KreisID", "Durchmesser", "Umfang", "Radius", "Fl�che" }; + int i = 0; + myRS.next(); + do { + int id = myRS.getInt("KreisID"); + Double d = myRS.getDouble("d"); + Double U = myRS.getDouble("U"); + Double r = myRS.getDouble("r"); + Double A = myRS.getDouble("A"); + data[i][0] = id + ""; + data[i][1] = d + ""; + data[i][2] = U + ""; + data[i][3] = r + ""; + data[i][4] = A + ""; + i++; + } while (myRS.next()); + model = new DefaultTableModel(data, columns) { + @Override + public boolean isCellEditable(int row, int column) { + // all cells false + return false; + } + }; + + } catch (SQLException e) { + e.printStackTrace(); + } + break; + case "Quadrat": + try { + String data[][] = null; + String columns[] = { "QuadratID", "Seite A", "Fl�che", "Umfang", "Diagonale" }; + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); + myPrepStmnt = myCon.prepareStatement("SELECT * FROM quadrat", ResultSet.TYPE_SCROLL_SENSITIVE, + ResultSet.CONCUR_UPDATABLE); + myRS = myPrepStmnt.executeQuery(); + myRS.last(); + data = new String[myRS.getRow()][10]; + myRS.first(); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); + myPrepStmnt = myCon.prepareStatement("SELECT * FROM quadrat", ResultSet.TYPE_FORWARD_ONLY, + ResultSet.CONCUR_READ_ONLY); + myRS = myPrepStmnt.executeQuery(); + int row = 0; + myRS.next(); + do { + row++; + }while (myRS.next()); + data = new String[row][10]; + myRS = null; + myRS = myPrepStmnt.executeQuery(); + } - myPrepStmnt = myCon.prepareStatement("SELECT * FROM quadrat", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); - myRS = myPrepStmnt.executeQuery(); - myRS.last(); - String columns[] = { "QuadratID", "Seite A", "Fläche", "Umfang" , "Diagonale"}; - String data[][] = new String[myRS.getRow()][10]; - - int i = 0; - myRS.first(); - do { - int id = myRS.getInt("QuadratID"); - Double sidea = myRS.getDouble("sidea"); - Double A = myRS.getDouble("A"); - Double U = myRS.getDouble("U"); - Double d = myRS.getDouble("diag"); - data[i][0] = id + ""; - data[i][1] = sidea + ""; - data[i][2] = A + ""; - data[i][3] = U + ""; - data[i][4] = d + ""; - i++; - } while (myRS.next()); - model = new DefaultTableModel(data, columns) { - @Override - public boolean isCellEditable(int row, int column) { - //all cells false - return false; - } - }; - - } catch(SQLException e) { - e.printStackTrace(); + + + + int i = 0; + myRS.next(); + do { + int id = myRS.getInt("QuadratID"); + Double sidea = myRS.getDouble("sidea"); + Double A = myRS.getDouble("A"); + Double U = myRS.getDouble("U"); + Double d = myRS.getDouble("diag"); + data[i][0] = id + ""; + data[i][1] = sidea + ""; + data[i][2] = A + ""; + data[i][3] = U + ""; + data[i][4] = d + ""; + i++; + } while (myRS.next()); + model = new DefaultTableModel(data, columns) { + @Override + public boolean isCellEditable(int row, int column) { + // all cells false + return false; + } + }; + + } catch (SQLException e) { + e.printStackTrace(); + } + break; + + default: + break; } - break; - default: - break; + return model; } - - - - return model; -} - -/** - * - * Sends a Query to the Database and gets the parameters if it exists - * @param figur - * @param array - * @param array1 - * @return - */ -public static boolean getDB(Figur figur,ArrayList array, ArrayList array1) { - boolean ret = false; - //System.out.println(figur.getClass().getName()); - switch (figur.getClass().getName()) { - - case "Rechteck": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); - } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); - } - String query = "SELECT * FROM Rechteck WHERE "+array.get(0)+"="+array1.get(0)+" AND "+array.get(1)+"="+array1.get(1); - //System.out.println(query); - Statement st = myCon.createStatement(); - myRS = st.executeQuery(query); - if(myRS.next()) { - //System.out.println("test"); - ((Rechteck) figur).setSidea(myRS.getDouble(2)); - ((Rechteck) figur).setSideb(myRS.getDouble(3)); - ((Rechteck) figur).setD(myRS.getDouble(4)); - figur.setA(myRS.getDouble(5)); - figur.setU(myRS.getDouble(6)); - ((Rechteck) figur).setAlpha(myRS.getDouble(7)); - ((Rechteck) figur).setBeta(myRS.getDouble(8)); - ((Rechteck) figur).setGamma(myRS.getDouble(9)); - ((Rechteck) figur).setDelta(myRS.getDouble(10)); - ret = true; + + /** + * + * Sends a Query to the Database and gets the parameters if it exists + * + * @param figur + * @param array + * @param array1 + * @return + */ + public static boolean getDB(Figur figur, ArrayList array, ArrayList array1) { + boolean ret = false; + // System.out.println(figur.getClass().getName()); + switch (figur.getClass().getName()) { + + case "Rechteck": + try { + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); + } else if (type.equals("SQLite")) { + myCon = DriverManager.getConnection(url); } - - myCon.close(); - myCon = null; - st=null; - query = null; - //ret = true; - } catch (SQLException e) { - e.printStackTrace(); - } finally { - Datenbank.doFinally(); - } - break; - case "Dreieck": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); + String query = "SELECT * FROM Rechteck WHERE " + array.get(0) + "=" + array1.get(0) + " AND " + + array.get(1) + "=" + array1.get(1); + // System.out.println(query); + Statement st = myCon.createStatement(); + myRS = st.executeQuery(query); + if (myRS.next()) { + // System.out.println("test"); + ((Rechteck) figur).setSidea(myRS.getDouble(2)); + ((Rechteck) figur).setSideb(myRS.getDouble(3)); + ((Rechteck) figur).setD(myRS.getDouble(4)); + figur.setA(myRS.getDouble(5)); + figur.setU(myRS.getDouble(6)); + ((Rechteck) figur).setAlpha(myRS.getDouble(7)); + ((Rechteck) figur).setBeta(myRS.getDouble(8)); + ((Rechteck) figur).setGamma(myRS.getDouble(9)); + ((Rechteck) figur).setDelta(myRS.getDouble(10)); + ret = true; + } + + myCon.close(); + myCon = null; + st = null; + query = null; + // ret = true; + } catch (SQLException e) { + e.printStackTrace(); + } finally { + Datenbank.doFinally(); + } + break; + case "Dreieck": + try { + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); } - String query = "SELECT * FROM Dreieck WHERE "+array.get(0)+"="+array1.get(0)+" AND "+array.get(1)+"="+array1.get(1)+" AND "+array.get(2)+"="+array1.get(2); - //System.out.println(query); - Statement st = myCon.createStatement(); - myRS = st.executeQuery(query); - if(myRS.next()) { - //System.out.println("test"); - ((Dreieck) figur).setSidea(myRS.getDouble(2)); - ((Dreieck) figur).setB(myRS.getDouble(3)); - ((Dreieck) figur).setC(myRS.getDouble(4)); - ((Dreieck) figur).setAlpha(myRS.getDouble(5)); - ((Dreieck) figur).setBeta(myRS.getDouble(6)); - ((Dreieck) figur).setGamma(myRS.getDouble(7)); - figur.setU(myRS.getDouble(8)); - figur.setA(myRS.getDouble(9)); - ((Dreieck) figur).setHeighta(myRS.getDouble(10)); - ((Dreieck) figur).setHeightb(myRS.getDouble(11)); - ((Dreieck) figur).setHeightc(myRS.getDouble(12)); - ((Dreieck) figur).setInradius(myRS.getDouble(13)); - ((Dreieck) figur).setUmradius(myRS.getDouble(14)); - ret = true; + String query = "SELECT * FROM Dreieck WHERE " + array.get(0) + "=" + array1.get(0) + " AND " + + array.get(1) + "=" + array1.get(1) + " AND " + array.get(2) + "=" + array1.get(2); + // System.out.println(query); + Statement st = myCon.createStatement(); + myRS = st.executeQuery(query); + if (myRS.next()) { + // System.out.println("test"); + ((Dreieck) figur).setSidea(myRS.getDouble(2)); + ((Dreieck) figur).setB(myRS.getDouble(3)); + ((Dreieck) figur).setC(myRS.getDouble(4)); + ((Dreieck) figur).setAlpha(myRS.getDouble(5)); + ((Dreieck) figur).setBeta(myRS.getDouble(6)); + ((Dreieck) figur).setGamma(myRS.getDouble(7)); + figur.setU(myRS.getDouble(8)); + figur.setA(myRS.getDouble(9)); + ((Dreieck) figur).setHeighta(myRS.getDouble(10)); + ((Dreieck) figur).setHeightb(myRS.getDouble(11)); + ((Dreieck) figur).setHeightc(myRS.getDouble(12)); + ((Dreieck) figur).setInradius(myRS.getDouble(13)); + ((Dreieck) figur).setUmradius(myRS.getDouble(14)); + ret = true; } - - myCon.close(); - myCon = null; - st=null; - query = null; - - } catch (SQLException e) { - e.printStackTrace(); - } finally { - Datenbank.doFinally(); - } - break; - case "Kreis": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); + + myCon.close(); + myCon = null; + st = null; + query = null; + + } catch (SQLException e) { + e.printStackTrace(); + } finally { + Datenbank.doFinally(); + } + break; + case "Kreis": + try { + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); } - String query = "SELECT * FROM Kreis WHERE "+array.get(0)+"="+array1.get(0); - //System.out.println(query); - Statement st = myCon.createStatement(); - myRS = st.executeQuery(query); - if(myRS.next()) { - //System.out.println("test"); - ((Kreis) figur).setD(myRS.getDouble(2)); - figur.setU(myRS.getDouble(3)); - ((Kreis) figur).setR(myRS.getDouble(4)); - figur.setA(myRS.getDouble(5)); - ret = true; + String query = "SELECT * FROM Kreis WHERE " + array.get(0) + "=" + array1.get(0); + // System.out.println(query); + Statement st = myCon.createStatement(); + myRS = st.executeQuery(query); + if (myRS.next()) { + // System.out.println("test"); + ((Kreis) figur).setD(myRS.getDouble(2)); + figur.setU(myRS.getDouble(3)); + ((Kreis) figur).setR(myRS.getDouble(4)); + figur.setA(myRS.getDouble(5)); + ret = true; } - - myCon.close(); - myCon = null; - st=null; - query = null; - //ret = true; - } catch (SQLException e) { - e.printStackTrace(); - } finally { - Datenbank.doFinally(); - } - break; - case "Quadrat": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); + + myCon.close(); + myCon = null; + st = null; + query = null; + // ret = true; + } catch (SQLException e) { + e.printStackTrace(); + } finally { + Datenbank.doFinally(); + } + break; + case "Quadrat": + try { + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); } - String query = "SELECT * FROM Quadrat WHERE "+array.get(0)+"="+array1.get(0); - //System.out.println(query); - Statement st = myCon.createStatement(); - myRS = st.executeQuery(query); - if(myRS.next()) { - //System.out.println("test"); - ((Quadrat) figur).setSidea(myRS.getDouble(2)); - figur.setA(myRS.getDouble(3)); - figur.setU(myRS.getDouble(4)); - ((Quadrat) figur).setD(myRS.getDouble(5)); - ret = true; + String query = "SELECT * FROM Quadrat WHERE " + array.get(0) + "=" + array1.get(0); + // System.out.println(query); + Statement st = myCon.createStatement(); + myRS = st.executeQuery(query); + if (myRS.next()) { + // System.out.println("test"); + ((Quadrat) figur).setSidea(myRS.getDouble(2)); + figur.setA(myRS.getDouble(3)); + figur.setU(myRS.getDouble(4)); + ((Quadrat) figur).setD(myRS.getDouble(5)); + ret = true; } - - myCon.close(); - myCon = null; - st=null; - query = null; - //ret = true; - } catch (SQLException e) { - e.printStackTrace(); - } finally { - Datenbank.doFinally(); + + myCon.close(); + myCon = null; + st = null; + query = null; + // ret = true; + } catch (SQLException e) { + e.printStackTrace(); + } finally { + Datenbank.doFinally(); + } + break; + default: + break; } - break; - default: - break; + + return ret; } - - return ret; -} + /** + * Export a resource embedded into a Jar file to the local file path. + * + * @param resourceName ie.: "/SmartLibrary.dll" + * @return The path to the exported resource + * @throws Exception + */ -/** - * Export a resource embedded into a Jar file to the local file path. - * - * @param resourceName ie.: "/SmartLibrary.dll" - * @return The path to the exported resource - * @throws Exception - */ - - -/** - * Saves the Object into the Database. - * @param figur - * @return - */ -public static boolean save_DB(Figur figur) { - boolean ret = false; - switch (figur.getClass().getName()) { - case "Quadrat": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); - myCon.setAutoCommit(true); + /** + * Saves the Object into the Database. + * + * @param figur + * @return + */ + public static boolean save_DB(Figur figur) { + boolean ret = false; + switch (figur.getClass().getName()) { + case "Quadrat": + try { + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); + myCon.setAutoCommit(true); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); } - myPrepStmnt = myCon.prepareStatement("INSERT INTO Quadrat(sidea, A, U, diag) VALUES (?,?,?,?)"); - myPrepStmnt.setDouble(1, ((Quadrat) figur).getSidea()); - myPrepStmnt.setDouble(2, figur.getA()); - myPrepStmnt.setDouble(3, figur.getU()); - myPrepStmnt.setDouble(4, ((Quadrat) figur).getD()); - myPrepStmnt.executeUpdate(); - ret = true; - } catch (SQLException e) { - ret = false; - e.printStackTrace(); - } finally { - Datenbank.doFinally(); - } - break; - case "Dreieck": - try { - //System.out.println("test"); - //System.out.println(figur.getSidea()); - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); + myPrepStmnt = myCon.prepareStatement("INSERT INTO Quadrat(sidea, A, U, diag) VALUES (?,?,?,?)"); + myPrepStmnt.setDouble(1, ((Quadrat) figur).getSidea()); + myPrepStmnt.setDouble(2, figur.getA()); + myPrepStmnt.setDouble(3, figur.getU()); + myPrepStmnt.setDouble(4, ((Quadrat) figur).getD()); + myPrepStmnt.executeUpdate(); + ret = true; + } catch (SQLException e) { + ret = false; + e.printStackTrace(); + } finally { + Datenbank.doFinally(); + } + break; + case "Dreieck": + try { + // System.out.println("test"); + // System.out.println(figur.getSidea()); + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); } - myPrepStmnt = myCon.prepareStatement("INSERT INTO Dreieck(Sidea, Sideb, Sidec, alpha, beta, gamma, ha, hb, hc, flaeche, umfang, inradius, umradius) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"); - myPrepStmnt.setDouble(1, ((Dreieck) figur).getSidea()); - myPrepStmnt.setDouble(2, ((Dreieck) figur).getB()); - myPrepStmnt.setDouble(3, ((Dreieck) figur).getC()); - myPrepStmnt.setDouble(4, ((Dreieck) figur).getAlpha()); - myPrepStmnt.setDouble(5, ((Dreieck) figur).getBeta()); - myPrepStmnt.setDouble(6, ((Dreieck) figur).getGamma()); - myPrepStmnt.setDouble(7, ((Dreieck) figur).getHeighta()); - myPrepStmnt.setDouble(8, ((Dreieck) figur).getHeightb()); - myPrepStmnt.setDouble(9, ((Dreieck) figur).getHeightc()); - myPrepStmnt.setDouble(10, figur.getA()); - myPrepStmnt.setDouble(11, figur.getU()); - myPrepStmnt.setDouble(12, ((Dreieck) figur).getInradius()); - myPrepStmnt.setDouble(13, ((Dreieck) figur).getUmradius()); - myPrepStmnt.executeUpdate(); - ret = true; - } catch (SQLException e) { - ret = false; - e.printStackTrace(); - } finally { - Datenbank.doFinally(); - } - break; - case "Rechteck": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); + myPrepStmnt = myCon.prepareStatement( + "INSERT INTO Dreieck(Sidea, Sideb, Sidec, alpha, beta, gamma, ha, hb, hc, flaeche, umfang, inradius, umradius) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"); + myPrepStmnt.setDouble(1, ((Dreieck) figur).getSidea()); + myPrepStmnt.setDouble(2, ((Dreieck) figur).getB()); + myPrepStmnt.setDouble(3, ((Dreieck) figur).getC()); + myPrepStmnt.setDouble(4, ((Dreieck) figur).getAlpha()); + myPrepStmnt.setDouble(5, ((Dreieck) figur).getBeta()); + myPrepStmnt.setDouble(6, ((Dreieck) figur).getGamma()); + myPrepStmnt.setDouble(7, ((Dreieck) figur).getHeighta()); + myPrepStmnt.setDouble(8, ((Dreieck) figur).getHeightb()); + myPrepStmnt.setDouble(9, ((Dreieck) figur).getHeightc()); + myPrepStmnt.setDouble(10, figur.getA()); + myPrepStmnt.setDouble(11, figur.getU()); + myPrepStmnt.setDouble(12, ((Dreieck) figur).getInradius()); + myPrepStmnt.setDouble(13, ((Dreieck) figur).getUmradius()); + myPrepStmnt.executeUpdate(); + ret = true; + } catch (SQLException e) { + ret = false; + e.printStackTrace(); + } finally { + Datenbank.doFinally(); + } + break; + case "Rechteck": + try { + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); } - myPrepStmnt = myCon.prepareStatement("INSERT INTO Rechteck(Sidea, Sideb, diag, area, Umfang, alpha, beta, gamma, delta) VALUES (?,?,?,?,?,?,?,?,?)"); - myPrepStmnt.setDouble(1, ((Rechteck) figur).getSidea()); - myPrepStmnt.setDouble(2, ((Rechteck) figur).getSideb()); - myPrepStmnt.setDouble(3, ((Rechteck) figur).getD()); - myPrepStmnt.setDouble(4, figur.getA()); - myPrepStmnt.setDouble(5, figur.getU()); - myPrepStmnt.setDouble(6, ((Rechteck) figur).getAlpha()); - myPrepStmnt.setDouble(7, ((Rechteck) figur).getBeta()); - myPrepStmnt.setDouble(8, ((Rechteck) figur).getGamma()); - myPrepStmnt.setDouble(9, ((Rechteck) figur).getDelta()); - myPrepStmnt.executeUpdate(); - ret = true; - } catch (SQLException e) { - ret = false; - e.printStackTrace(); - } finally { - Datenbank.doFinally(); - } - break; - case "Kreis": - try { - if (type.equals("MySQL")) { - myCon = DriverManager.getConnection(url, user, pwd); + myPrepStmnt = myCon.prepareStatement( + "INSERT INTO Rechteck(Sidea, Sideb, diag, area, Umfang, alpha, beta, gamma, delta) VALUES (?,?,?,?,?,?,?,?,?)"); + myPrepStmnt.setDouble(1, ((Rechteck) figur).getSidea()); + myPrepStmnt.setDouble(2, ((Rechteck) figur).getSideb()); + myPrepStmnt.setDouble(3, ((Rechteck) figur).getD()); + myPrepStmnt.setDouble(4, figur.getA()); + myPrepStmnt.setDouble(5, figur.getU()); + myPrepStmnt.setDouble(6, ((Rechteck) figur).getAlpha()); + myPrepStmnt.setDouble(7, ((Rechteck) figur).getBeta()); + myPrepStmnt.setDouble(8, ((Rechteck) figur).getGamma()); + myPrepStmnt.setDouble(9, ((Rechteck) figur).getDelta()); + myPrepStmnt.executeUpdate(); + ret = true; + } catch (SQLException e) { + ret = false; + e.printStackTrace(); + } finally { + Datenbank.doFinally(); + } + break; + case "Kreis": + try { + if (type.equals("MySQL")) { + myCon = DriverManager.getConnection(url, user, pwd); } else if (type.equals("SQLite")) { - myCon = DriverManager.getConnection(url); + myCon = DriverManager.getConnection(url); } - myPrepStmnt = myCon.prepareStatement("INSERT INTO Kreis(d,U, r, A) VALUES (?,?,?,?)"); - myPrepStmnt.setDouble(1, ((Kreis) figur).getD()); - myPrepStmnt.setDouble(2, figur.getU()); - myPrepStmnt.setDouble(3, ((Kreis) figur).getR()); - myPrepStmnt.setDouble(4, figur.getA()); - myPrepStmnt.executeUpdate(); - ret = true; - } catch (SQLException e) { - ret = false; - e.printStackTrace(); - } finally { - Datenbank.doFinally(); + myPrepStmnt = myCon.prepareStatement("INSERT INTO Kreis(d,U, r, A) VALUES (?,?,?,?)"); + myPrepStmnt.setDouble(1, ((Kreis) figur).getD()); + myPrepStmnt.setDouble(2, figur.getU()); + myPrepStmnt.setDouble(3, ((Kreis) figur).getR()); + myPrepStmnt.setDouble(4, figur.getA()); + myPrepStmnt.executeUpdate(); + ret = true; + } catch (SQLException e) { + ret = false; + e.printStackTrace(); + } finally { + Datenbank.doFinally(); + } + break; } - break; + return ret; } - return ret; -} /** * Does Close all Open Connections. */ private static void doFinally() { - if(myRS != null) { + if (myRS != null) { try { myRS.close(); myRS = null; } catch (SQLException e) { e.printStackTrace(); } - + } - if(myPrepStmnt != null) { + if (myPrepStmnt != null) { try { myPrepStmnt.close(); myPrepStmnt = null; - } catch (SQLException e){ + } catch (SQLException e) { e.printStackTrace(); } } - if(myCon != null) { + if (myCon != null) { try { myCon.close(); myCon = null; @@ -598,5 +668,5 @@ private static void doFinally() { } } }; - + } diff --git a/src/Dreieck.java b/src/Dreieck.java index 167a2bd..e852d28 100644 --- a/src/Dreieck.java +++ b/src/Dreieck.java @@ -2,954 +2,1067 @@ public class Dreieck extends Figur { //variables -private Double sidea; -private Double sideb; -private Double sidec; -private Double alpha; -private Double beta; -private Double gamma; -private Double ha; -private Double hb; -private Double hc; -private Double Inradius; -private Double Umradius; + private Double sidea; + private Double sideb; + private Double sidec; + private Double alpha; + private Double beta; + private Double gamma; + private Double ha; + private Double hb; + private Double hc; + private Double Inradius; + private Double Umradius; + // Getter & Setter -public Double getSidea() { - return sidea; -} -public void setSidea(Double a) { - this.sidea = a; -} -public Double getB() { - return sideb; -} -public void setB(Double b) { - this.sideb = b; -} -public Double getC() { - return sidec; -} -public void setC(Double c) { - this.sidec = c; -} -public Double getAlpha() { - return alpha; -} -public void setAlpha(Double alpha) { - this.alpha = alpha; -} -public Double getBeta() { - return beta; -} -public void setBeta(Double beta) { - this.beta = beta; -} -public Double getGamma() { - return gamma; -} -public void setGamma(Double gamma) { - this.gamma = gamma; -} -public Double getHeighta() { - return ha; -} -public void setHeighta(Double heighta) { - this.ha = heighta; -} + public Double getSidea() { + return sidea; + } -public Double getHeightb() { - return hb; -} -public void setHeightb(Double heightb) { - this.hb = heightb; -} -public Double getHeightc() { - return hc; -} -public void setHeightc(Double heightc) { - this.hc = heightc; -} + public void setSidea(Double a) { + this.sidea = a; + } + + public Double getB() { + return sideb; + } + + public void setB(Double b) { + this.sideb = b; + } + + public Double getC() { + return sidec; + } + + public void setC(Double c) { + this.sidec = c; + } + + public Double getAlpha() { + return alpha; + } + + public void setAlpha(Double alpha) { + this.alpha = alpha; + } + + public Double getBeta() { + return beta; + } + + public void setBeta(Double beta) { + this.beta = beta; + } + + public Double getGamma() { + return gamma; + } + + public void setGamma(Double gamma) { + this.gamma = gamma; + } + + public Double getHeighta() { + return ha; + } + + public void setHeighta(Double heighta) { + this.ha = heighta; + } + + public Double getHeightb() { + return hb; + } + + public void setHeightb(Double heightb) { + this.hb = heightb; + } + + public Double getHeightc() { + return hc; + } + + public void setHeightc(Double heightc) { + this.hc = heightc; + } + + public Double getInradius() { + return Inradius; + } + + public void setInradius(Double inradius) { + Inradius = inradius; + } + + public Double getUmradius() { + return Umradius; + } + + public void setUmradius(Double umradius) { + Umradius = umradius; + } -public Double getInradius() { - return Inradius; -} -public void setInradius(Double inradius) { - Inradius = inradius; -} -public Double getUmradius() { - return Umradius; -} -public void setUmradius(Double umradius) { - Umradius = umradius; -} // Constructor -public Dreieck() { - super(); -} -public Dreieck(Double a, Double b, Double c, Double alpha, Double beta, Double gamma, Double heighta, Double heightb, Double heightc, Double Inradius, Double Umradius) { - super(); - this.sidea = a; - this.sideb = b; - this.sidec = c; - this.alpha = alpha; - this.beta = beta; - this.gamma = gamma; - this.ha = heighta; - this.hb = heightb; - this.hc = heightc; - this.Inradius = Inradius; - this.Umradius = Umradius; -} + public Dreieck() { + super(); + } + + public Dreieck(Double a, Double b, Double c, Double alpha, Double beta, Double gamma, Double heighta, + Double heightb, Double heightc, Double Inradius, Double Umradius) { + super(); + this.sidea = a; + this.sideb = b; + this.sidec = c; + this.alpha = alpha; + this.beta = beta; + this.gamma = gamma; + this.ha = heighta; + this.hb = heightb; + this.hc = heightc; + this.Inradius = Inradius; + this.Umradius = Umradius; + } //Functions -/** - * Calculates all Values for the Triangle - */ -public void calculate() { - //System.out.println(sidea); - if(sidea != null) { - if(sideb != null) { - if(sidec != null) { - if( !((sidea+sideb)<=sidec) && !((sidea+sidec)<=sideb) && !((sideb+sidec)<=sidea)){ + /** + * Calculates all Values for the Triangle + */ + public void calculate() { + // System.out.println(sidea); + if (sidea != null) { + if (sideb != null) { + if (sidec != null) { + if (!((sidea + sideb) <= sidec) && !((sidea + sidec) <= sideb) && !((sideb + sidec) <= sidea)) { + getAngle("alpha"); + getAngle("beta"); + getAngle("gamma"); + } + } else if (alpha != null) { + getAngle("beta"); + getAngle("gamma"); + sidec = (Math.sin(Math.toRadians(gamma)) * sidea) / Math.sin(Math.toRadians(alpha)); + } else if (beta != null) { + getAngle("alpha"); + getAngle("gamma"); + sidec = (Math.sin(Math.toRadians(gamma)) * sidea) / Math.sin(Math.toRadians(alpha)); + + } else if (gamma != null) { + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); getAngle("alpha"); getAngle("beta"); + + } else if (ha != null) { // 2 l�sungen getAngle("gamma"); - } - } else if (alpha != null) { - getAngle("beta"); - getAngle("gamma"); - sidec = (Math.sin(Math.toRadians(gamma))*sidea) /Math.sin(Math.toRadians(alpha)); - } else if (beta !=null) { - getAngle("alpha"); - getAngle("gamma"); - sidec = (Math.sin(Math.toRadians(gamma))*sidea) /Math.sin(Math.toRadians(alpha)); - - } else if (gamma !=null) { - sidec = Math.sqrt(Math.pow(sidea, 2)+Math.pow(sideb, 2)-2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - - } else if (ha !=null) { // 2 lösungen - getAngle("gamma"); - sidec = (Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma)))); - getAngle("alpha"); - getAngle("beta"); - - } else if (hb !=null) { - A = hb*sideb/2; - ha = 2*A/sidea; - getAngle("gamma"); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - - } else if (hc !=null) { - getAngle("beta"); - getAngle("alpha"); - getAngle("gamma"); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - + sidec = (Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma)))); + getAngle("alpha"); + getAngle("beta"); + + } else if (hb != null) { + A = hb * sideb / 2; + ha = 2 * A / sidea; + getAngle("gamma"); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + + } else if (hc != null) { + getAngle("beta"); + getAngle("alpha"); + getAngle("gamma"); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + } else if (U != null) { sidec = U - sidea - sideb; getAngle("alpha"); getAngle("beta"); getAngle("gamma"); - + } else if (A != null) { - ha = 2*A/sidea; + ha = 2 * A / sidea; getAngle("gamma"); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); getAngle("alpha"); - getAngle("beta"); + getAngle("beta"); } - } else if (sidec !=null) { + } else if (sidec != null) { if (alpha != null) { getAngle("gamma"); getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - - } else if (beta !=null) { - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - - } else if (gamma !=null) { - getAngle("alpha"); - getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - - } else if (ha !=null) { - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("beta"); - getAngle("alpha"); - getAngle("gamma"); - - } else if (hb !=null) { - getAngle("gamma"); - getAngle("alpha"); - getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - - } else if (hc !=null) { - A = hc*sidec/2; - ha = 2*A/sidea; - getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + + } else if (beta != null) { + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + + } else if (gamma != null) { + getAngle("alpha"); + getAngle("beta"); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + + } else if (ha != null) { + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("beta"); + getAngle("alpha"); + getAngle("gamma"); + + } else if (hb != null) { + getAngle("gamma"); + getAngle("alpha"); + getAngle("beta"); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + + } else if (hc != null) { + A = hc * sidec / 2; + ha = 2 * A / sidea; + getAngle("beta"); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + } else if (U != null) { - sideb = U - sidea- sidec; - getAngle("alpha"); - getAngle("beta"); - getAngle("gamma"); - + sideb = U - sidea - sidec; + getAngle("alpha"); + getAngle("beta"); + getAngle("gamma"); + } else if (A != null) { - ha = 2*A/sidec; - getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - - } - + ha = 2 * A / sidec; + getAngle("beta"); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + + } + } else if (alpha != null) { - if (beta !=null) { - getAngle("gamma"); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if (gamma !=null) { - getAngle("beta"); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if (hb !=null) { - sidec = hb/Math.sin(Math.toRadians(alpha)); - getAngle("gamma"); - getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(gamma))); - - } else if (hc !=null) { - sideb = hc/Math.sin(Math.toRadians(alpha)); - getAngle("beta"); - getAngle("gamma"); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - } - } else if (beta !=null) { - - if (gamma !=null) { - getAngle("alpha"); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if (ha !=null) { - sidec = ha/Math.sin(Math.toRadians(beta)); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - - } else if (hb !=null) { - hc = sidea/Math.sin(Math.toRadians(beta)); - getAngle("gamma"); - getAngle("alpha"); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - A = hb*sideb/2; - sidec = 2*A/hc; - + if (beta != null) { + getAngle("gamma"); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (gamma != null) { + getAngle("beta"); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (hb != null) { + sidec = hb / Math.sin(Math.toRadians(alpha)); + getAngle("gamma"); + getAngle("beta"); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(gamma))); + + } else if (hc != null) { + sideb = hc / Math.sin(Math.toRadians(alpha)); + getAngle("beta"); + getAngle("gamma"); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + } + } else if (beta != null) { + + if (gamma != null) { + getAngle("alpha"); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (ha != null) { + sidec = ha / Math.sin(Math.toRadians(beta)); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + + } else if (hb != null) { + hc = sidea / Math.sin(Math.toRadians(beta)); + getAngle("gamma"); + getAngle("alpha"); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + A = hb * sideb / 2; + sidec = 2 * A / hc; + } else if (A != null) { - ha = 2*A/sidea; - sidec = ha/Math.sin(Math.toRadians(beta)); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - - } - } else if (gamma !=null) { - - if (ha !=null) { - sideb = ha/Math.sin(Math.toRadians(gamma)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - - } else if (hc !=null) { - getAngle("beta"); - getAngle("alpha"); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - A = hb*sideb/2; - sidec = 2*A/hc; - + ha = 2 * A / sidea; + sidec = ha / Math.sin(Math.toRadians(beta)); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + + } + } else if (gamma != null) { + + if (ha != null) { + sideb = ha / Math.sin(Math.toRadians(gamma)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + + } else if (hc != null) { + getAngle("beta"); + getAngle("alpha"); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + A = hb * sideb / 2; + sidec = 2 * A / hc; + } else if (A != null) { - ha = 2*A/sidea; - sideb = ha/Math.sin(Math.toRadians(gamma)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - + ha = 2 * A / sidea; + sideb = ha / Math.sin(Math.toRadians(gamma)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + } } else if (ha != null) { if (hb != null) { - A = ha*sidea/2; - sideb = 2*A/hb; - getAngle("gamma"); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - - } else if (hc !=null) { - A = ha*sidea/2; - sidec = 2*A/hc; - getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - + A = ha * sidea / 2; + sideb = 2 * A / hb; + getAngle("gamma"); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + + } else if (hc != null) { + A = ha * sidea / 2; + sidec = 2 * A / hc; + getAngle("beta"); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + } } else if (hb != null) { if (hc != null) { - getAngle("gamma"); - getAngle("beta"); + getAngle("gamma"); + getAngle("beta"); getAngle("alpha"); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - A = hb*sideb/2; - sidec = 2*A/hc; - + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + A = hb * sideb / 2; + sidec = 2 * A / hc; + } else if (A != null) { - sideb = 2*A/hb; - ha = 2*A/sidea; - getAngle("gamma"); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - + sideb = 2 * A / hb; + ha = 2 * A / sidea; + getAngle("gamma"); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + } } else if (hc != null) { if (A != null) { - sidec = 2*A/hc; - ha = 2*A/sidec; - getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); + sidec = 2 * A / hc; + ha = 2 * A / sidec; + getAngle("beta"); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); } } - } else if(sideb != null) { - if(sidec != null) { - if(alpha != null) { - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - - } else if(beta != null) { - getAngle("gamma"); - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - - } else if(gamma != null) { - getAngle("beta"); - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - - } else if(ha != null) { - getAngle("gamma"); - getAngle("beta"); - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - - } else if(hb != null) { - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - - } else if(hc != null) { - A = hc * sidec/2; - hb = 2*A/sideb; - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - + } else if (sideb != null) { + if (sidec != null) { + if (alpha != null) { + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + + } else if (beta != null) { + getAngle("gamma"); + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + + } else if (gamma != null) { + getAngle("beta"); + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + + } else if (ha != null) { + getAngle("gamma"); + getAngle("beta"); + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + + } else if (hb != null) { + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + + } else if (hc != null) { + A = hc * sidec / 2; + hb = 2 * A / sideb; + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + } else if (U != null) { - sidea = U - sideb- sidec; - getAngle("alpha"); - getAngle("beta"); - getAngle("gamma"); - + sidea = U - sideb - sidec; + getAngle("alpha"); + getAngle("beta"); + getAngle("gamma"); + } else if (A != null) { - hb = 2*A/sideb; - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - - } - } else if(alpha != null) { - if(beta != null) { - getAngle("gamma"); - sidea = sideb*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(beta)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if(gamma != null) { - getAngle("beta"); - sidea = sideb*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(beta)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if(ha != null) { - hc = sideb*Math.sin(Math.toRadians(alpha)); - getAngle("gamma"); - getAngle("beta"); - sidea = sideb*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(beta)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if(hb != null) { - sidec = hb/Math.sin(Math.toRadians(alpha)); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - + hb = 2 * A / sideb; + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + + } + } else if (alpha != null) { + if (beta != null) { + getAngle("gamma"); + sidea = sideb * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(beta)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (gamma != null) { + getAngle("beta"); + sidea = sideb * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(beta)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (ha != null) { + hc = sideb * Math.sin(Math.toRadians(alpha)); + getAngle("gamma"); + getAngle("beta"); + sidea = sideb * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(beta)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (hb != null) { + sidec = hb / Math.sin(Math.toRadians(alpha)); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + } else if (A != null) { - hb = 2*A/sideb; - sidec = hb/Math.sin(Math.toRadians(alpha)); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - } - } else if(beta != null) { - if(gamma != null) { - getAngle("alpha"); - sidea = sideb*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(beta)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if(ha != null) { - sidec = ha/Math.sin(Math.toRadians(beta)); - getAngle("gamma"); - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - - } else if(hc != null) { - sidea = hc/Math.sin(Math.toRadians(beta)); - getAngle("alpha"); - getAngle("gamma"); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } - } else if(gamma != null) { - if(hb != null) { - A = hb*sideb/2; - sidea = 2*A/ha; - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - - } else if(hc != null) { - ha = sideb/Math.sin(Math.toRadians(gamma)); - getAngle("alpha"); - getAngle("beta"); - sidea = sideb*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(beta)); - A = ha*sidea/2; - sidec = 2*A/hc; - + hb = 2 * A / sideb; + sidec = hb / Math.sin(Math.toRadians(alpha)); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + } + } else if (beta != null) { + if (gamma != null) { + getAngle("alpha"); + sidea = sideb * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(beta)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (ha != null) { + sidec = ha / Math.sin(Math.toRadians(beta)); + getAngle("gamma"); + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + + } else if (hc != null) { + sidea = hc / Math.sin(Math.toRadians(beta)); + getAngle("alpha"); + getAngle("gamma"); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } + } else if (gamma != null) { + if (hb != null) { + A = hb * sideb / 2; + sidea = 2 * A / ha; + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + + } else if (hc != null) { + ha = sideb / Math.sin(Math.toRadians(gamma)); + getAngle("alpha"); + getAngle("beta"); + sidea = sideb * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(beta)); + A = ha * sidea / 2; + sidec = 2 * A / hc; + } else if (A != null) { - ha = sideb*Math.sin(Math.toRadians(gamma)); - sidea = 2*A/ha; - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - - } - } else if(ha != null) { + ha = sideb * Math.sin(Math.toRadians(gamma)); + sidea = 2 * A / ha; + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + + } + } else if (ha != null) { if (hb != null) { - A = hb*sideb/2; - sidea = 2*A/ha; - getAngle("gamma"); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - + A = hb * sideb / 2; + sidea = 2 * A / ha; + getAngle("gamma"); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + } else if (hc != null) { - getAngle("gamma"); - getAngle("alpha"); - getAngle("beta"); - sidea = sideb*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(beta)); - A = ha*sidea/2; - sidec = 2*A/hc; - + getAngle("gamma"); + getAngle("alpha"); + getAngle("beta"); + sidea = sideb * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(beta)); + A = ha * sidea / 2; + sidec = 2 * A / hc; + } else if (A != null) { - sidea = 2*A/ha; - getAngle("gamma"); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - - } - } else if(hb != null) { - if(hc != null) { - A = hb*sideb/2; - sidec = 2*A/hc; - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - + sidea = 2 * A / ha; + getAngle("gamma"); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + + } + } else if (hb != null) { + if (hc != null) { + A = hb * sideb / 2; + sidec = 2 * A / hc; + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + } } - } else if(sidec != null) { + } else if (sidec != null) { if (alpha != null) { - if(beta != null) { - getAngle("gamma"); - sidea = sidec*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(gamma)); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - - } else if(gamma != null) { - getAngle("beta"); - sidea = sidec*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(gamma)); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - - } else if(ha != null) { - hb = sidec*Math.sin(Math.toRadians(alpha)); - getAngle("beta"); - getAngle("gamma"); - sidea = sidec*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(gamma)); - A = ha*sidea/2; - sideb = 2*A/hb; - - } else if(hc != null) { - A = hc*sidec/2; - hb = sidec*Math.sin(Math.toRadians(alpha)); - sideb = 2*A/hb; - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - + if (beta != null) { + getAngle("gamma"); + sidea = sidec * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(gamma)); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + + } else if (gamma != null) { + getAngle("beta"); + sidea = sidec * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(gamma)); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + + } else if (ha != null) { + hb = sidec * Math.sin(Math.toRadians(alpha)); + getAngle("beta"); + getAngle("gamma"); + sidea = sidec * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(gamma)); + A = ha * sidea / 2; + sideb = 2 * A / hb; + + } else if (hc != null) { + A = hc * sidec / 2; + hb = sidec * Math.sin(Math.toRadians(alpha)); + sideb = 2 * A / hb; + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + } else if (A != null) { - hb = sidec*Math.sin(Math.toRadians(alpha)); - sideb = 2*A/hb; - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - - } - } else if(beta != null) { - if(gamma != null) { - getAngle("alpha"); - sidea = sidec*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(gamma)); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - - } else if(hb != null) { - ha = sidec*Math.sin(Math.toRadians(beta)); - getAngle("alpha"); - getAngle("gamma"); - sidea = sidec*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(gamma)); - A = ha * sidea/2; - sideb = 2*A/hb; - - } else if(hc != null) { - A = hc * sidec/2; - ha = sidec*Math.sin(Math.toRadians(beta)); - sidea = 2*A/ha; - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - + hb = sidec * Math.sin(Math.toRadians(alpha)); + sideb = 2 * A / hb; + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + + } + } else if (beta != null) { + if (gamma != null) { + getAngle("alpha"); + sidea = sidec * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(gamma)); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + + } else if (hb != null) { + ha = sidec * Math.sin(Math.toRadians(beta)); + getAngle("alpha"); + getAngle("gamma"); + sidea = sidec * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(gamma)); + A = ha * sidea / 2; + sideb = 2 * A / hb; + + } else if (hc != null) { + A = hc * sidec / 2; + ha = sidec * Math.sin(Math.toRadians(beta)); + sidea = 2 * A / ha; + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + } else if (A != null) { - ha = sidec*Math.sin(Math.toRadians(beta)); - sidea = 2*A/ha; - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - - } - } else if(gamma != null) { - if(ha != null) { - sideb = ha/Math.sin(Math.toRadians(gamma)); - getAngle("beta"); - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - - } else if(hb != null) { - sidea = hb/Math.sin(Math.toRadians(gamma)); - getAngle("alpha"); - getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - - } - } else if(ha != null) { + ha = sidec * Math.sin(Math.toRadians(beta)); + sidea = 2 * A / ha; + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + + } + } else if (gamma != null) { + if (ha != null) { + sideb = ha / Math.sin(Math.toRadians(gamma)); + getAngle("beta"); + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + + } else if (hb != null) { + sidea = hb / Math.sin(Math.toRadians(gamma)); + getAngle("alpha"); + getAngle("beta"); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + + } + } else if (ha != null) { if (hb != null) { - getAngle("beta"); - getAngle("alpha"); - getAngle("gamma"); - sidea = sidec*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(gamma)); - A = ha*sidea/2; - sideb = 2*A/hb; - + getAngle("beta"); + getAngle("alpha"); + getAngle("gamma"); + sidea = sidec * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(gamma)); + A = ha * sidea / 2; + sideb = 2 * A / hb; + } else if (hc != null) { - A = hc*sidec/2; - sidea = 2*A/ha; - getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - + A = hc * sidec / 2; + sidea = 2 * A / ha; + getAngle("beta"); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + } else if (A != null) { - sidea = 2*A/ha; - getAngle("beta"); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - - } - } else if(hb != null) { - if(hc != null) { - A = hc*sidec/2; - sideb = 2*A/hb; - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - + sidea = 2 * A / ha; + getAngle("beta"); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + + } + } else if (hb != null) { + if (hc != null) { + A = hc * sidec / 2; + sideb = 2 * A / hb; + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + } else if (A != null) { - sideb = 2*A/hb; - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - + sideb = 2 * A / hb; + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + } } - } else if(alpha != null) { - if(beta != null) { - if(ha != null) { - getAngle("gamma"); - sideb = ha/Math.sin(Math.toRadians(gamma)); - sidea = sideb*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(beta)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if(hb != null) { - getAngle("gamma"); - sidea = hb/Math.sin(Math.toRadians(gamma)); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if(hc != null) { - getAngle("gamma"); - sidea = hc/Math.sin(Math.toRadians(beta)); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - + } else if (alpha != null) { + if (beta != null) { + if (ha != null) { + getAngle("gamma"); + sideb = ha / Math.sin(Math.toRadians(gamma)); + sidea = sideb * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(beta)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (hb != null) { + getAngle("gamma"); + sidea = hb / Math.sin(Math.toRadians(gamma)); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (hc != null) { + getAngle("gamma"); + sidea = hc / Math.sin(Math.toRadians(beta)); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + } else if (A != null) { - getAngle("gamma"); - Double ru = Math.sqrt(A/(2*Math.sin(Math.toRadians(alpha))*Math.sin(Math.toRadians(beta))*Math.sin(Math.toRadians(gamma)))); - sidea = 2*ru*Math.sin(Math.toRadians(alpha)); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - + getAngle("gamma"); + Double ru = Math.sqrt(A / (2 * Math.sin(Math.toRadians(alpha)) * Math.sin(Math.toRadians(beta)) + * Math.sin(Math.toRadians(gamma)))); + sidea = 2 * ru * Math.sin(Math.toRadians(alpha)); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + } else if (U != null) { - getAngle("gamma"); - Double ru = U/(8*Math.cos(Math.toRadians(alpha/2))*Math.cos(Math.toRadians(beta/2))*Math.cos(Math.toRadians(gamma/2))); - sidea = 2*ru*Math.sin(Math.toRadians(alpha)); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); + getAngle("gamma"); + Double ru = U / (8 * Math.cos(Math.toRadians(alpha / 2)) * Math.cos(Math.toRadians(beta / 2)) + * Math.cos(Math.toRadians(gamma / 2))); + sidea = 2 * ru * Math.sin(Math.toRadians(alpha)); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); sidec = U - sidea - sideb; - - } - } else if(gamma != null) { - if(ha != null) { - getAngle("beta"); - sideb = ha/Math.sin(Math.toRadians(gamma)); - sidea = sideb*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(beta)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if(hb != null) { - getAngle("beta"); - sidea = hb/Math.sin(Math.toRadians(gamma)); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if(hc != null) { - getAngle("beta"); - sidea = hc/Math.sin(Math.toRadians(beta)); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } - } else if(ha != null) { + + } + } else if (gamma != null) { + if (ha != null) { + getAngle("beta"); + sideb = ha / Math.sin(Math.toRadians(gamma)); + sidea = sideb * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(beta)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (hb != null) { + getAngle("beta"); + sidea = hb / Math.sin(Math.toRadians(gamma)); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (hc != null) { + getAngle("beta"); + sidea = hc / Math.sin(Math.toRadians(beta)); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } + } else if (ha != null) { if (hb != null) { - sidec = hb/Math.sin(Math.toRadians(alpha)); - getAngle("beta"); - getAngle("gamma"); - sidea = sidec*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(gamma)); - A = ha*sidea/2; - sideb = 2*A/hb; - + sidec = hb / Math.sin(Math.toRadians(alpha)); + getAngle("beta"); + getAngle("gamma"); + sidea = sidec * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(gamma)); + A = ha * sidea / 2; + sideb = 2 * A / hb; + } else if (hc != null) { - sideb = hc/Math.sin(Math.toRadians(alpha)); - getAngle("gamma"); - getAngle("beta"); - sidea = sideb*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(beta)); - A = ha*sidea/2; - sidec = 2*A/hc; - - } - } else if(hb != null) { - if(hc != null) { - sidec = hb/Math.sin(Math.toRadians(alpha)); - A = hc*sidec/2; - sideb = 2*A/hb; - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - + sideb = hc / Math.sin(Math.toRadians(alpha)); + getAngle("gamma"); + getAngle("beta"); + sidea = sideb * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(beta)); + A = ha * sidea / 2; + sidec = 2 * A / hc; + + } + } else if (hb != null) { + if (hc != null) { + sidec = hb / Math.sin(Math.toRadians(alpha)); + A = hc * sidec / 2; + sideb = 2 * A / hb; + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + } else if (A != null) { - sideb = 2*A/hb; - sidec = hb/Math.sin(Math.toRadians(alpha)); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - + sideb = 2 * A / hb; + sidec = hb / Math.sin(Math.toRadians(alpha)); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + } } - } else if(beta != null) { - if(gamma != null) { - if(ha != null) { - getAngle("alpha"); - sideb = ha/Math.sin(Math.toRadians(gamma)); - sidea = sideb*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(beta)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if(hb != null) { - getAngle("alpha"); - sidea = hb/Math.sin(Math.toRadians(gamma)); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - - } else if(hc != null) { - getAngle("alpha"); - sidea = hc/Math.sin(Math.toRadians(beta)); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - + } else if (beta != null) { + if (gamma != null) { + if (ha != null) { + getAngle("alpha"); + sideb = ha / Math.sin(Math.toRadians(gamma)); + sidea = sideb * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(beta)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (hb != null) { + getAngle("alpha"); + sidea = hb / Math.sin(Math.toRadians(gamma)); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + + } else if (hc != null) { + getAngle("alpha"); + sidea = hc / Math.sin(Math.toRadians(beta)); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + } else if (A != null) { - getAngle("alpha"); - double ru = Math.sqrt(A/(2*Math.sin(Math.toRadians(alpha))*Math.sin(Math.toRadians(beta))*Math.sin(Math.toRadians(gamma)))); - sidea = 2*ru*Math.sin(Math.toRadians(alpha)); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - + getAngle("alpha"); + double ru = Math.sqrt(A / (2 * Math.sin(Math.toRadians(alpha)) * Math.sin(Math.toRadians(beta)) + * Math.sin(Math.toRadians(gamma)))); + sidea = 2 * ru * Math.sin(Math.toRadians(alpha)); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + } else if (U != null) { - getAngle("alpha"); - Double ru = U /(8*Math.cos(Math.toRadians(alpha /2))*Math.cos(Math.toRadians(beta/2))*Math.cos(Math.toRadians(gamma/2))); - sidea = 2*ru*Math.sin(Math.toRadians(alpha)); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); + getAngle("alpha"); + Double ru = U / (8 * Math.cos(Math.toRadians(alpha / 2)) * Math.cos(Math.toRadians(beta / 2)) + * Math.cos(Math.toRadians(gamma / 2))); + sidea = 2 * ru * Math.sin(Math.toRadians(alpha)); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); sidec = U - sidea - sideb; - + } - } else if(ha != null) { + } else if (ha != null) { if (hb != null) { - sidec = hc/Math.sin(Math.toRadians(beta)); - getAngle("alpha"); - getAngle("gamma"); - sidea = sidec*Math.sin(Math.toRadians(alpha))/Math.sin(Math.toRadians(gamma)); - A = ha*sidea/2; - sideb = 2*A/sidec; - + sidec = hc / Math.sin(Math.toRadians(beta)); + getAngle("alpha"); + getAngle("gamma"); + sidea = sidec * Math.sin(Math.toRadians(alpha)) / Math.sin(Math.toRadians(gamma)); + A = ha * sidea / 2; + sideb = 2 * A / sidec; + } else if (hc != null) { - sidec = ha/Math.sin(Math.toRadians(beta)); - A = hc*sidec/2; - sidea = 2*A/ha; - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - + sidec = ha / Math.sin(Math.toRadians(beta)); + A = hc * sidec / 2; + sidea = 2 * A / ha; + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + } else if (A != null) { - sidea = 2*A/ha; - sidec = ha/Math.sin(Math.toRadians(beta)); - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - - } - } else if(hb != null) { - if(hc != null) { - sidea = hc/Math.sin(Math.toRadians(beta)); - getAngle("gamma"); - getAngle("alpha"); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - A = hb*sideb/2; - sidec = 2*A/hc; + sidea = 2 * A / ha; + sidec = ha / Math.sin(Math.toRadians(beta)); + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + + } + } else if (hb != null) { + if (hc != null) { + sidea = hc / Math.sin(Math.toRadians(beta)); + getAngle("gamma"); + getAngle("alpha"); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + A = hb * sideb / 2; + sidec = 2 * A / hc; } } else if (hc != null) { if (A != null) { - sidec = 2*A/hc; - sidea = 2*A/ha; - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - + sidec = 2 * A / hc; + sidea = 2 * A / ha; + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + } } - } else if(gamma != null) { - if(ha != null) { + } else if (gamma != null) { + if (ha != null) { if (hb != null) { - sideb = hb/Math.sin(Math.toRadians(gamma)); - A = hb*sideb/2; - sidea = 2*A/ha; - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - + sideb = hb / Math.sin(Math.toRadians(gamma)); + A = hb * sideb / 2; + sidea = 2 * A / ha; + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + } else if (hc != null) { - sideb = ha/Math.sin(Math.toRadians(gamma)); - getAngle("alpha"); - getAngle("beta"); - A = ha*sidea/2; - sidec = 2*A/hc; - + sideb = ha / Math.sin(Math.toRadians(gamma)); + getAngle("alpha"); + getAngle("beta"); + A = ha * sidea / 2; + sidec = 2 * A / hc; + } else if (A != null) { - sidea = 2*A/ha; - sideb = ha/Math.sin(Math.toRadians(gamma)); - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - - } - } else if(hb != null) { - if(hc != null) { - sidea = hb/Math.sin(Math.toRadians(gamma)); - getAngle("beta"); - getAngle("alpha"); - sideb = sidea*Math.sin(Math.toRadians(beta))/Math.sin(Math.toRadians(alpha)); - A = hb*sideb/2; - sidec = 2*A/hc; - + sidea = 2 * A / ha; + sideb = ha / Math.sin(Math.toRadians(gamma)); + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + + } + } else if (hb != null) { + if (hc != null) { + sidea = hb / Math.sin(Math.toRadians(gamma)); + getAngle("beta"); + getAngle("alpha"); + sideb = sidea * Math.sin(Math.toRadians(beta)) / Math.sin(Math.toRadians(alpha)); + A = hb * sideb / 2; + sidec = 2 * A / hc; + } else if (A != null) { - sideb = 2*A/hb; - ha = sideb/Math.sin(Math.toRadians(gamma)); - sidea = 2*A/ha; - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - + sideb = 2 * A / hb; + ha = sideb / Math.sin(Math.toRadians(gamma)); + sidea = 2 * A / ha; + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + } } } else if (ha != null) { - if(hb != null) { - if(hc != null) { - sidea = 2*ha*Math.pow(hb, 2)*Math.pow(hc, 2) / Math.sqrt(Math.pow(hb, 2) * Math.pow(hc, 2)*(2 * Math.pow(ha, 2)*(Math.pow(hb, 2)+Math.pow(hc, 2)) - Math.pow(hb, 2) * Math.pow(hc, 2)) - Math.pow(ha, 4) * (Math.pow(hb, 4) - 2*Math.pow(hb, 2)*Math.pow(hc, 2) + Math.pow(hc, 4))); - A = ha*sidea/2; - sideb = 2*A/hb; - sidec = 2*A/hc; - getAngle("alpha"); - getAngle("beta"); - getAngle("gamma"); + if (hb != null) { + if (hc != null) { + sidea = 2 * ha * Math.pow(hb, 2) * Math.pow(hc, 2) / Math.sqrt(Math.pow(hb, 2) * Math.pow(hc, 2) + * (2 * Math.pow(ha, 2) * (Math.pow(hb, 2) + Math.pow(hc, 2)) + - Math.pow(hb, 2) * Math.pow(hc, 2)) + - Math.pow(ha, 4) + * (Math.pow(hb, 4) - 2 * Math.pow(hb, 2) * Math.pow(hc, 2) + Math.pow(hc, 4))); + A = ha * sidea / 2; + sideb = 2 * A / hb; + sidec = 2 * A / hc; + getAngle("alpha"); + getAngle("beta"); + getAngle("gamma"); } else if (A != null) { - sidea = 2*A/ha; - sideb = 2*A/hb; - sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) - 2*sidea*sideb*Math.cos(Math.toRadians(gamma))); - getAngle("alpha"); - getAngle("beta"); - + sidea = 2 * A / ha; + sideb = 2 * A / hb; + sidec = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2) + - 2 * sidea * sideb * Math.cos(Math.toRadians(gamma))); + getAngle("alpha"); + getAngle("beta"); + } } else if (hc != null) { if (A != null) { - sidea = 2*A/ha; - sidec = 2*A/hc; - sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) - 2*sidea*sidec*Math.cos(Math.toRadians(beta))); - getAngle("alpha"); - getAngle("gamma"); - + sidea = 2 * A / ha; + sidec = 2 * A / hc; + sideb = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidec, 2) + - 2 * sidea * sidec * Math.cos(Math.toRadians(beta))); + getAngle("alpha"); + getAngle("gamma"); + } } } else if (hb != null) { if (hc != null) { if (A != null) { - sideb = 2*A/hb; - sidec = 2*A/hc; - getAngle("alpha"); - sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) - 2*sideb*sidec*Math.cos(Math.toRadians(alpha))); - getAngle("beta"); - getAngle("gamma"); - + sideb = 2 * A / hb; + sidec = 2 * A / hc; + getAngle("alpha"); + sidea = Math.sqrt(Math.pow(sideb, 2) + Math.pow(sidec, 2) + - 2 * sideb * sidec * Math.cos(Math.toRadians(alpha))); + getAngle("beta"); + getAngle("gamma"); + } } } - if(sidea!=null && sideb!=null && sidec!= null && gamma!=null && alpha!=null && beta!=null) { - + if (sidea != null && sideb != null && sidec != null && gamma != null && alpha != null && beta != null) { - + if (!(ha != null && hb != null && hc != null)) { + ha = (sideb * Math.sin(Math.toRadians(gamma))); + hb = (sidec * Math.sin(Math.toRadians(alpha))); + hc = (sidea * Math.sin(Math.toRadians(beta))); + } else { + System.out.println("test"); + } + double s = (sidea + sideb + sidec) / 2; + A = Math.sqrt(s * (s - sidea) * (s - sideb) * (s - sidec)); + Inradius = (A / s); + U = (sidea + sideb + sidec); - if (!(ha!=null && hb!=null && hc!=null)) { - ha = (sideb*Math.sin(Math.toRadians(gamma))); - hb = (sidec*Math.sin(Math.toRadians(alpha))); - hc = (sidea*Math.sin(Math.toRadians(beta))); - } else { - System.out.println("test"); - } - double s = (sidea+sideb+sidec)/2; - A = Math.sqrt(s*(s-sidea)*(s-sideb)*(s-sidec)); - Inradius = (A/s); - U = (sidea + sideb + sidec); - - Umradius = (sidea*sideb*sidec)/(4*Inradius*s); + Umradius = (sidea * sideb * sidec) / (4 * Inradius * s); // if (sidea>0 && sidea>0 && sidec>0 && alpha>0 && beta>0 && gamma>0 && U>0 && hb>0 && A>0) { // Datenbank.save_dreieck(test); // } + } } -} + private void getAngle(String search) { - //Double angle=null; + // Double angle=null; switch (search) { case "alpha": - if (sideb != null && sidec !=null && sidea !=null) { - alpha = Math.toDegrees(Math.acos((Math.pow(sideb, 2) + Math.pow(sidec, 2) - Math.pow(sidea, 2) ) / (2*sideb*sidec))); - } else if (sidea!=null && beta!=null && sideb != null) { - alpha = Math.toDegrees(Math.asin(sidea*Math.sin(Math.toRadians(beta))/sideb)); - } else if (sidea!=null && sidec!=null && gamma!=null) { - alpha = Math.toDegrees(Math.asin(Math.sin(Math.toRadians(gamma))*sidea/sidec)); - } else if (gamma !=null && beta !=null) { - alpha = (180-gamma-beta); - } else if (hb!=null && sidec!=null) { - alpha = Math.toDegrees(Math.asin(hb/sidec)); - } else if (hc!=null && sideb!=null) { - alpha = Math.toDegrees(Math.asin(hc/sideb)); + if (sideb != null && sidec != null && sidea != null) { + alpha = Math.toDegrees(Math + .acos((Math.pow(sideb, 2) + Math.pow(sidec, 2) - Math.pow(sidea, 2)) / (2 * sideb * sidec))); + } else if (sidea != null && beta != null && sideb != null) { + alpha = Math.toDegrees(Math.asin(sidea * Math.sin(Math.toRadians(beta)) / sideb)); + } else if (sidea != null && sidec != null && gamma != null) { + alpha = Math.toDegrees(Math.asin(Math.sin(Math.toRadians(gamma)) * sidea / sidec)); + } else if (gamma != null && beta != null) { + alpha = (180 - gamma - beta); + } else if (hb != null && sidec != null) { + alpha = Math.toDegrees(Math.asin(hb / sidec)); + } else if (hc != null && sideb != null) { + alpha = Math.toDegrees(Math.asin(hc / sideb)); } break; case "beta": - if (sideb != null && sidec !=null && sidea !=null) { - beta = Math.toDegrees(Math.acos((Math.pow(sidec, 2) + Math.pow(sidea, 2) - Math.pow(sideb, 2) ) / (2*sidec*sidea))); - } else if (sideb !=null && alpha!=null && sidea!=null) { - beta = Math.toDegrees(Math.asin((sideb*Math.sin(Math.toRadians(alpha))/sidea))); - //beta = Math.toDegrees(Math.asin(Math.sin(Math.toRadians(alpha))*sideb/sidea)); - } else if (sideb !=null && gamma!=null && sidec!=null) { - beta = Math.toDegrees(Math.asin(Math.sin(Math.toRadians(gamma))*sideb/sidec)); - } else if (hc!=null&&sidea!=null) { - beta = Math.toDegrees(Math.asin(hc/sidea)); - } else if (hc!=null&&sidec!=null) { - beta = Math.toDegrees(Math.asin(ha/sidec)); - } else if (gamma !=null && alpha !=null) { - beta = (180-alpha-gamma); - } else if (gamma !=null && sidea !=null) { + if (sideb != null && sidec != null && sidea != null) { + beta = Math.toDegrees(Math + .acos((Math.pow(sidec, 2) + Math.pow(sidea, 2) - Math.pow(sideb, 2)) / (2 * sidec * sidea))); + } else if (sideb != null && alpha != null && sidea != null) { + beta = Math.toDegrees(Math.asin((sideb * Math.sin(Math.toRadians(alpha)) / sidea))); + // beta = + // Math.toDegrees(Math.asin(Math.sin(Math.toRadians(alpha))*sideb/sidea)); + } else if (sideb != null && gamma != null && sidec != null) { + beta = Math.toDegrees(Math.asin(Math.sin(Math.toRadians(gamma)) * sideb / sidec)); + } else if (hc != null && sidea != null) { + beta = Math.toDegrees(Math.asin(hc / sidea)); + } else if (hc != null && sidec != null) { + beta = Math.toDegrees(Math.asin(ha / sidec)); + } else if (gamma != null && alpha != null) { + beta = (180 - alpha - gamma); + } else if (gamma != null && sidea != null) { beta = sidea * Math.toDegrees(Math.asin(gamma)); } break; case "gamma": - if (sideb != null && sidec !=null && sidea !=null) { - gamma = Math.toDegrees(Math.acos((Math.pow(sidea, 2) + Math.pow(sideb, 2) - Math.pow(sidec, 2) ) / (2*sidea*sideb))); - } else if (ha!=null && sideb!=null) { - gamma = Math.toDegrees(Math.asin(ha/sideb)); - } else if (hb!=null && sidea!=null) { - gamma = Math.toDegrees(Math.asin(hb/sidea)); - } else if (alpha!=null && sidec!=null && sidea!=null) { - gamma = Math.toDegrees(Math.asin(Math.sin(Math.toRadians(alpha))*sidec/sidea)); - } else if (beta!=null && sidec!=null && sideb!=null) { - gamma = Math.toDegrees(Math.asin(Math.sin(Math.toRadians(beta))*sidec/sideb)); - } else if (alpha !=null && beta !=null) { - gamma = (180-alpha-beta); - } + if (sideb != null && sidec != null && sidea != null) { + gamma = Math.toDegrees(Math + .acos((Math.pow(sidea, 2) + Math.pow(sideb, 2) - Math.pow(sidec, 2)) / (2 * sidea * sideb))); + } else if (ha != null && sideb != null) { + gamma = Math.toDegrees(Math.asin(ha / sideb)); + } else if (hb != null && sidea != null) { + gamma = Math.toDegrees(Math.asin(hb / sidea)); + } else if (alpha != null && sidec != null && sidea != null) { + gamma = Math.toDegrees(Math.asin(Math.sin(Math.toRadians(alpha)) * sidec / sidea)); + } else if (beta != null && sidec != null && sideb != null) { + gamma = Math.toDegrees(Math.asin(Math.sin(Math.toRadians(beta)) * sidec / sideb)); + } else if (alpha != null && beta != null) { + gamma = (180 - alpha - beta); + } break; default: - + break; - } - } + } + } } diff --git a/src/Figur.java b/src/Figur.java index ce49835..732f745 100644 --- a/src/Figur.java +++ b/src/Figur.java @@ -1,25 +1,25 @@ - public class Figur { protected Double A; protected Double U; - - + public Double getA() { return A; } + public void setA(Double a) { A = a; } + public Double getU() { return U; } + public void setU(Double u) { U = u; } - + public Figur() { super(); } } - diff --git a/src/Geometrie.db b/src/Geometrie.db index db10d2b6dfb320aa1f0d6e4be4432f82fd43021e..91d12d05b16e588702a4d1d45d147ad9d6ae606e 100644 GIT binary patch delta 3139 zcmcguU1%It6rRZ@`#<;YXeW24n@!fWrum)h?Ck8$N|S72e%mH#W1_~tvgvM{G(WUS zN}*QQw5SNBq|SqsDhT?ZEux{)A}ELtwn!@!3>5kzilr#%LlHr!cb#!lTz>z=LVo{Le^=DgKRD9e+dbR_@RO6dd^YMS4#%SfHqK3E4_at;uDCur zb09lgM5hl=*ly$b1$%TbJ2PVsbNOi--80-j&@ns~+0{K(S4tw%F*-8TKM33hx(7$< zz4eQgZWjrK3j9e2%k;?6Y;G>QU_UC>CuyTrYI`lq4VlfaW!7P(GHN|mb6ZEP7^Kh@ z-9&AV(@7c|`LUuPlMDHM^Z6r3^RxS@KBZIFI-VOA>t?ev`6lqJM*>&PM4mY*Rk+v) zqB}iKt^i%ao#X)wh4@p}mbtn7BuHmJoa?rT+Nf2EF3a-4rJz+Ax9UKL`)!feu;!4SEUD?+N+f_$v9f3dKG*d+3!s3+2 zs!>HzfyFUE!eRcDg%q2+_}p+Litv9s39AR8U>E6sI|&so7a@dSoMh=v6+qPaDSC6P zm!4r(QoHE#2HA5KZ@ca1teJHd)@e}m-PHHciO)k9niug{m0#%M@HM=I$MB=*7xW1_ zhBC+_+!W3UU6&$(ZGxF<9Tk#3A16r?uqQ+|&$l)TNpC5#0*LNeLx_pm8U)>4iu3@I zbgd#XF<)tG6w*!~M~2GnyzUu)Dm%3QPW%f zwyOb{o>X)_P3`oAl1K%8PRLOr)KfJS1LDDwp~O=`ueCz=Q{#P#o{F;(41(|)p-wbj zTvt?$+UPOrDd1gp0if0jIjggAQ6kStk4n{1Y#C7_LqZicp41NmN zpr6r4=rA%6CwwEE7WCysNx-9ipXe%HYWz}H>sMvl0;rS2ckp-kGkhK|;)8f6ZovU` z4}Fg=qqos<^aAR~B& z!=N9bD>tjjV7@1WD-%^J4b&rYp%L0e#`bO0=_R<3YL^XkjIu2!hzuhjL`n zLd$@@N-R|g%EK|2sJhk;V4)aV5M-ww=5IB@%ykZ5#?v^8ZlN=%NBCR#Sa?nl{a^d% z{o8yizBhas?;qZa-mF*leCv71)8M}Ce#^bnUFQ1Sb=VblUSD2(-6;-5F>N^Ol8Gdl z7iu%&-bYGMCd2*OPO&$F?UxVbMs0_;8)9$GM)X}kd#X!OFgNdRPl-KM7D}D12=Tg< z*c)P~OfiZQ^F*B?4r~PuG+Fv5%Ya_3YZHfLK!GPS22?hK^%-#>$oN_j2t}vr+r$CF zPAbBhb_Jgr8o0^K>Ht}%pj^AftbHH zJT7(zthja>V7sF+DelIAQqNTmuQj%c1BgZdcr~|`M&K)KL~EM>^;;1@B8WokaEzip znwymboCZLz0ov!?$X9Moi+eoO*1n*2#LP8!h(m77!C_ggS;)N7oDq9mEP|Z`>}Yxv z(9Oxvl9~+z+E-!QuGZna0yQhQP)gU*_zp!K45iZ9sM-Q(nT0Z2dNWT@l;4P6ZE5wF z;~N~lhwtLs_y)X!{t}j#zU0${r{ClLaz~gieuemb4o8T$zhFgAnS=1`A9=vX177@` F`v+4AgiQbd delta 1543 zcmZ`(O>7%Q6t*45rj2(d4%$pNwi64XvY*17NRSIhB(89%fJ-kNxbohtQwao?{O0+4Kl9$3 z@A=j*`CFgm@6@U!m&=X9_xMvhJgZ!i;}=^FKt;@3%L0l3ud8y`OAC zY<3pUuP!fMT5euiv^kGqOnavY@K@ND-o%i8W%`+A1#+}O6x z8_B*sueEn~tB&*osiu zv?cv-0a;z!)_vRhZtb*T7zu{me9}SpdavE--rUR3p+5IU-d3G{Mc3=&Vl(IlS{*QX4N-UB;L&5%>Kt0HGuZA-EC^TBTR z`$C6YYVD)h@GxqSp*a9EU;#!4m`8*>HZu;GYaSCSy?23~oUWiZ{FLdp7bg2NV?(P@ z5szY_hgWE>L#-i4i->ukr%#k9W{<72@+HPdiNzViO*HjXiDF~X zfAm!^m--YNGXhH%aR?HcLzPFqSF)jQh=@WV(JkUZ?2Tq7ZR2bN3eCgtR1r)ra{~nc z)au)z1Y8E*NEW1QiB|Y?;9$6KSOKG4SKXa%EDxJ#HW8aPS2D8mcG8uEBUMf+WkTFaPB1~VuVkTBbE$ktJFw^P1 zEAhliF@v9Y2k9ROk60K+G)$sWbrs-323v0wGJPN6{J&t49$j6iR~(b0NAzQQ8R~vS zz9ctDL~_m#&TYrQ-vx8hrN-Le_QE@bXDFG^(O>EJ^gjKNCUlw3Q%e3MKa+>#6Y?%u zCG&%7t4Ip7G<|`e&XaVD&z`9xznJTZz`i2PJ&s_cKvU3y8A~@-1NME*S-*~SLuV$y^p=PGF!=_=K<_ z(s*TjKbM&hHbq|cVIdS(f#tw75DaEp3k_TzNgJdLFa^v8oTh lines = Arrays.asList("// MySQL oder SQLite", "DB_TYPE=SQLite", "DB_HOST=localhost", "DB_TABLE=tai21_geometrie", "DB_USER=root", "DB_PASSWORD=1111", "COMMA=2"); + List lines = Arrays.asList("// MySQL oder SQLite", "DB_TYPE=SQLite", + "DB_HOST=localhost", "DB_TABLE=tai21_geometrie", "DB_USER=root", + "DB_PASSWORD=1111"); Path file = Paths.get("config.cfg"); Files.write(file, lines, StandardCharsets.UTF_8); } catch (IOException e) { e.printStackTrace(); - + } JFrame frmerror = new JFrame(); - JOptionPane.showMessageDialog(frmerror, "Config not Found. \na new Config has been Created. \nUsing Default Config.", "Error", JOptionPane.INFORMATION_MESSAGE); - propsInput = new FileInputStream(configFilePath); + JOptionPane.showMessageDialog(frmerror, + "Config not Found. \na new Config has been Created. \nUsing Default Config.", "Error", + JOptionPane.INFORMATION_MESSAGE); + propsInput = new FileInputStream(configFilePath); } Properties prop = new Properties(); prop.load(propsInput); - //System.out.println(prop.getProperty("DB_USER")); - //for the Debug: jdbc:mysql://localhost/tai21_geometrie?profileSQL=true - String url = "jdbc:mysql://"+prop.getProperty("DB_HOST")+"/"+prop.getProperty("DB_TABLE"); + // System.out.println(prop.getProperty("DB_USER")); + // for the Debug: jdbc:mysql://localhost/tai21_geometrie?profileSQL=true + String url = "jdbc:mysql://" + prop.getProperty("DB_HOST") + "/" + prop.getProperty("DB_TABLE") + + "?profileSQL=true"; String user = prop.getProperty("DB_USER"); String pwd = prop.getProperty("DB_PASSWORD"); String type = prop.getProperty("DB_TYPE"); - String comma = prop.getProperty("COMMA"); - try { - if (Integer.valueOf(comma)!=null && Double.parseDouble(comma) > 0) { - String comma2 = String.valueOf(comma); - div = (int) Math.pow(10, Double.parseDouble(comma2)); - //System.out.println(comma2); - } - } catch (NumberFormatException g) { - JFrame frmerror = new JFrame(); - JOptionPane.showMessageDialog(frmerror, "No Decimals at comma in Config. using fallback.", "Error", JOptionPane.ERROR_MESSAGE); - } - if(Datenbank.testDB(url, user, pwd, type)) { + + if (Datenbank.testDB(url, user, pwd, type)) { Main_Geometrie window = new Main_Geometrie(); window.frmGeometrie.setVisible(true); } else { JFrame frmerror = new JFrame(); - JOptionPane.showMessageDialog(frmerror, "Cannot Connect to Database.", "Error", JOptionPane.ERROR_MESSAGE); - } - + JOptionPane.showMessageDialog(frmerror, "Cannot Connect to Database.", "Error", + JOptionPane.ERROR_MESSAGE); + } + } catch (Exception e) { e.printStackTrace(); System.exit(1); @@ -140,7 +133,7 @@ public void run() { } }); } - + /** * Create the application. */ @@ -148,8 +141,6 @@ public Main_Geometrie() { myCL = new CardLayout(); initialize(); myCL.show(frmGeometrie.getContentPane(), "panel_Main"); - - } /** @@ -163,70 +154,70 @@ private void initialize() { frmGeometrie.setBounds(100, 100, 900, 600); frmGeometrie.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frmGeometrie.getContentPane().setLayout(myCL); - + JLayeredPane layeredPane_Main = new JLayeredPane(); frmGeometrie.getContentPane().add(layeredPane_Main, "panel_Main"); - + JPanel panel_Main_1 = new JPanel(); panel_Main_1.setBorder(null); panel_Main_1.setOpaque(false); - + JPanel panel_Main_2 = new JPanel(); GroupLayout gl_layeredPane_Main = new GroupLayout(layeredPane_Main); gl_layeredPane_Main.setHorizontalGroup( - gl_layeredPane_Main.createParallelGroup(Alignment.LEADING) - .addGap(0, 884, Short.MAX_VALUE) - .addComponent(panel_Main_1, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) - .addComponent(panel_Main_2, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) - ); + gl_layeredPane_Main.createParallelGroup(Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE) + .addComponent(panel_Main_1, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) + .addComponent(panel_Main_2, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE)); gl_layeredPane_Main.setVerticalGroup( - gl_layeredPane_Main.createParallelGroup(Alignment.LEADING) - .addGap(0, 539, Short.MAX_VALUE) - .addComponent(panel_Main_1, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) - .addComponent(panel_Main_2, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) - ); + gl_layeredPane_Main.createParallelGroup(Alignment.LEADING).addGap(0, 539, Short.MAX_VALUE) + .addComponent(panel_Main_1, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) + .addComponent(panel_Main_2, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE)); panel_Main_2.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); - + JLabel lblNewLabel = new JLabel(""); - // bild einfügen + // bild einf�gen try { BufferedImage image = ImageIO.read(getClass().getResourceAsStream("Dreieck.png")); - lblNewLabel.setIcon(new ImageIcon(resizeImage(image, (int) Math.round(250/1), (int) Math.round(160/1)))); + lblNewLabel + .setIcon(new ImageIcon(resizeImage(image, (int) Math.round(250 / 1), (int) Math.round(160 / 1)))); } catch (IOException e1) { e1.printStackTrace(); } panel_Main_2.add(lblNewLabel); - + JLabel lblNewLabel_1 = new JLabel(""); - // bild einfügen + // bild einf�gen try { BufferedImage image = ImageIO.read(getClass().getResourceAsStream("Quadrat.png")); - lblNewLabel_1.setIcon(new ImageIcon(resizeImage(image, (int) Math.round(295/1), (int) Math.round(284/1)))); + lblNewLabel_1 + .setIcon(new ImageIcon(resizeImage(image, (int) Math.round(295 / 1), (int) Math.round(284 / 1)))); } catch (IOException e1) { e1.printStackTrace(); } panel_Main_2.add(lblNewLabel_1); - + JLabel lblNewLabel_2 = new JLabel(""); - // bild einfügen + // bild einf�gen try { BufferedImage image = ImageIO.read(getClass().getResourceAsStream("Rechteck.png")); - lblNewLabel_2.setIcon(new ImageIcon(resizeImage(image, (int) Math.round(356/1) , (int) Math.round(190/1) ))); + lblNewLabel_2 + .setIcon(new ImageIcon(resizeImage(image, (int) Math.round(356 / 1), (int) Math.round(190 / 1)))); } catch (IOException e1) { e1.printStackTrace(); } panel_Main_2.add(lblNewLabel_2); - + JLabel lblNewLabel_3 = new JLabel(""); - // bild einfügen + // bild einf�gen try { BufferedImage image = ImageIO.read(getClass().getResourceAsStream("Kreis.png")); - lblNewLabel_3.setIcon(new ImageIcon(resizeImage(image, (int) Math.round(200/1), (int) Math.round(200/1)))); + lblNewLabel_3 + .setIcon(new ImageIcon(resizeImage(image, (int) Math.round(200 / 1), (int) Math.round(200 / 1)))); } catch (IOException e1) { e1.printStackTrace(); } panel_Main_2.add(lblNewLabel_3); - + JButton btnDreieck = new JButton("Dreieck"); btnDreieck.setToolTipText("Hier kannst du ein Dreieck berechnen"); btnDreieck.addActionListener(new ActionListener() { @@ -237,7 +228,7 @@ public void actionPerformed(ActionEvent e) { FlowLayout fl_panel_Main_1 = new FlowLayout(FlowLayout.CENTER, 50, 250); panel_Main_1.setLayout(fl_panel_Main_1); panel_Main_1.add(btnDreieck); - + JButton btnQuadrat = new JButton("Quadrat"); btnQuadrat.setToolTipText("Hier kannst du ein Quadrat berechnen"); btnQuadrat.addActionListener(new ActionListener() { @@ -246,7 +237,7 @@ public void actionPerformed(ActionEvent e) { } }); panel_Main_1.add(btnQuadrat); - + JButton btnKreis = new JButton("Kreis"); btnKreis.setToolTipText("Hier kannst du ein Kreis berechnen"); btnKreis.addActionListener(new ActionListener() { @@ -255,7 +246,7 @@ public void actionPerformed(ActionEvent e) { } }); panel_Main_1.add(btnKreis); - + JButton btnRechteck = new JButton("Rechteck"); btnRechteck.setToolTipText("Hier kannst du ein Rechteck berechnen"); btnRechteck.addActionListener(new ActionListener() { @@ -265,34 +256,30 @@ public void actionPerformed(ActionEvent e) { }); panel_Main_1.add(btnRechteck); layeredPane_Main.setLayout(gl_layeredPane_Main); - - - + JLayeredPane layeredPane_Dreieck = new JLayeredPane(); frmGeometrie.getContentPane().add(layeredPane_Dreieck, "panel_Dreieck"); - + JPanel panel_Dreieck_1 = new JPanel(); GridBagLayout gbl_panel_Dreieck_1 = new GridBagLayout(); panel_Dreieck_1.setOpaque(false); - gbl_panel_Dreieck_1.columnWidths = new int[]{50, 0, 25, 0, 25, 0, 25, 50, 0, 0, 0}; - gbl_panel_Dreieck_1.rowHeights = new int[]{200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - gbl_panel_Dreieck_1.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; - gbl_panel_Dreieck_1.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; + gbl_panel_Dreieck_1.columnWidths = new int[] { 50, 0, 25, 0, 25, 0, 25, 50, 0, 0, 0 }; + gbl_panel_Dreieck_1.rowHeights = new int[] { 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + gbl_panel_Dreieck_1.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + Double.MIN_VALUE }; + gbl_panel_Dreieck_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + Double.MIN_VALUE }; panel_Dreieck_1.setLayout(gbl_panel_Dreieck_1); - + JPanel panel_Dreieck_Bild = new JPanel(); GroupLayout gl_layeredPane_Dreieck = new GroupLayout(layeredPane_Dreieck); - gl_layeredPane_Dreieck.setHorizontalGroup( - gl_layeredPane_Dreieck.createParallelGroup(Alignment.LEADING) + gl_layeredPane_Dreieck.setHorizontalGroup(gl_layeredPane_Dreieck.createParallelGroup(Alignment.LEADING) .addComponent(panel_Dreieck_1, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) - .addComponent(panel_Dreieck_Bild, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) - ); - gl_layeredPane_Dreieck.setVerticalGroup( - gl_layeredPane_Dreieck.createParallelGroup(Alignment.LEADING) + .addComponent(panel_Dreieck_Bild, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE)); + gl_layeredPane_Dreieck.setVerticalGroup(gl_layeredPane_Dreieck.createParallelGroup(Alignment.LEADING) .addComponent(panel_Dreieck_1, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) - .addComponent(panel_Dreieck_Bild, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) - ); - + .addComponent(panel_Dreieck_Bild, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE)); + tf_Dreieck_Umfang = new JTextField(); GridBagConstraints gbc_tf_Dreieck_Umfang = new GridBagConstraints(); gbc_tf_Dreieck_Umfang.insets = new Insets(0, 0, 5, 5); @@ -301,7 +288,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Dreieck_Umfang.gridy = 1; panel_Dreieck_1.add(tf_Dreieck_Umfang, gbc_tf_Dreieck_Umfang); tf_Dreieck_Umfang.setColumns(10); - + tf_Dreieck_Flaeche = new JTextField(); GridBagConstraints gbc_tf_Dreieck_Flaeche = new GridBagConstraints(); gbc_tf_Dreieck_Flaeche.insets = new Insets(0, 0, 5, 5); @@ -310,35 +297,35 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Dreieck_Flaeche.gridy = 2; panel_Dreieck_1.add(tf_Dreieck_Flaeche, gbc_tf_Dreieck_Flaeche); tf_Dreieck_Flaeche.setColumns(10); - + JLabel lbl_Dreieck_Umradius_Ergebnis = new JLabel(""); GridBagConstraints gbc_lbl_Dreieck_Umradius_Ergebnis = new GridBagConstraints(); gbc_lbl_Dreieck_Umradius_Ergebnis.insets = new Insets(0, 0, 5, 5); gbc_lbl_Dreieck_Umradius_Ergebnis.gridx = 8; gbc_lbl_Dreieck_Umradius_Ergebnis.gridy = 4; panel_Dreieck_1.add(lbl_Dreieck_Umradius_Ergebnis, gbc_lbl_Dreieck_Umradius_Ergebnis); - + JLabel lbl_Dreieck_Umradius = new JLabel("Umradius"); GridBagConstraints gbc_lbl_Dreieck_Umradius = new GridBagConstraints(); gbc_lbl_Dreieck_Umradius.insets = new Insets(0, 0, 5, 5); gbc_lbl_Dreieck_Umradius.gridx = 7; gbc_lbl_Dreieck_Umradius.gridy = 4; panel_Dreieck_1.add(lbl_Dreieck_Umradius, gbc_lbl_Dreieck_Umradius); - + JLabel lbl_Dreieck_Inradius_Ergebnis = new JLabel(""); GridBagConstraints gbc_lbl_Dreieck_Inradius_Ergebnis = new GridBagConstraints(); gbc_lbl_Dreieck_Inradius_Ergebnis.insets = new Insets(0, 0, 5, 5); gbc_lbl_Dreieck_Inradius_Ergebnis.gridx = 8; gbc_lbl_Dreieck_Inradius_Ergebnis.gridy = 3; panel_Dreieck_1.add(lbl_Dreieck_Inradius_Ergebnis, gbc_lbl_Dreieck_Inradius_Ergebnis); - + JLabel lbl_Dreieck_Inradius = new JLabel("Inradius"); GridBagConstraints gbc_lbl_Dreieck_Inradius = new GridBagConstraints(); gbc_lbl_Dreieck_Inradius.insets = new Insets(0, 0, 5, 5); gbc_lbl_Dreieck_Inradius.gridx = 7; gbc_lbl_Dreieck_Inradius.gridy = 3; panel_Dreieck_1.add(lbl_Dreieck_Inradius, gbc_lbl_Dreieck_Inradius); - + tf_Dreieck_heightc = new JTextField(); tf_Dreieck_heightc.setToolTipText("Hier musst du die H\u00F6he von c eingeben."); GridBagConstraints gbc_tf_Dreieck_heightc = new GridBagConstraints(); @@ -348,7 +335,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Dreieck_heightc.gridy = 3; panel_Dreieck_1.add(tf_Dreieck_heightc, gbc_tf_Dreieck_heightc); tf_Dreieck_heightc.setColumns(10); - + tf_Dreieck_heightb = new JTextField(); tf_Dreieck_heightb.setToolTipText("Hier musst du die H\u00F6he von b eingeben."); GridBagConstraints gbc_tf_Dreieck_heightb = new GridBagConstraints(); @@ -358,35 +345,35 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Dreieck_heightb.gridy = 3; panel_Dreieck_1.add(tf_Dreieck_heightb, gbc_tf_Dreieck_heightb); tf_Dreieck_heightb.setColumns(10); - + JLabel lblHeightc = new JLabel("H\u00F6he c"); GridBagConstraints gbc_lblHeightc = new GridBagConstraints(); gbc_lblHeightc.insets = new Insets(0, 0, 5, 5); gbc_lblHeightc.gridx = 5; gbc_lblHeightc.gridy = 3; panel_Dreieck_1.add(lblHeightc, gbc_lblHeightc); - + JLabel lblHeightb = new JLabel("H\u00F6he b"); GridBagConstraints gbc_lblHeightb = new GridBagConstraints(); gbc_lblHeightb.insets = new Insets(0, 0, 5, 5); gbc_lblHeightb.gridx = 3; gbc_lblHeightb.gridy = 3; panel_Dreieck_1.add(lblHeightb, gbc_lblHeightb); - + JLabel lblDreieck_Umfang = new JLabel("Umfang"); GridBagConstraints gbc_lblDreieck_Umfang = new GridBagConstraints(); gbc_lblDreieck_Umfang.insets = new Insets(0, 0, 5, 5); gbc_lblDreieck_Umfang.gridx = 7; gbc_lblDreieck_Umfang.gridy = 1; panel_Dreieck_1.add(lblDreieck_Umfang, gbc_lblDreieck_Umfang); - + JLabel lblDreieck_Flaeche = new JLabel("Fl\u00E4che"); GridBagConstraints gbc_lblDreieck_Flaeche = new GridBagConstraints(); gbc_lblDreieck_Flaeche.insets = new Insets(0, 0, 5, 5); gbc_lblDreieck_Flaeche.gridx = 7; gbc_lblDreieck_Flaeche.gridy = 2; panel_Dreieck_1.add(lblDreieck_Flaeche, gbc_lblDreieck_Flaeche); - + JLabel lblDreieck_a = new JLabel("a"); GridBagConstraints gbc_lblDreieck_a = new GridBagConstraints(); gbc_lblDreieck_a.anchor = GridBagConstraints.EAST; @@ -394,10 +381,10 @@ public void actionPerformed(ActionEvent e) { gbc_lblDreieck_a.gridx = 1; gbc_lblDreieck_a.gridy = 1; panel_Dreieck_1.add(lblDreieck_a, gbc_lblDreieck_a); - + tf_Dreieck_a = new JTextField(); tf_Dreieck_a.setToolTipText("Hier musst du die Seite a eingeben.\r\n"); - + GridBagConstraints gbc_tf_Dreieck_a = new GridBagConstraints(); gbc_tf_Dreieck_a.insets = new Insets(0, 0, 5, 5); gbc_tf_Dreieck_a.fill = GridBagConstraints.HORIZONTAL; @@ -405,7 +392,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Dreieck_a.gridy = 1; panel_Dreieck_1.add(tf_Dreieck_a, gbc_tf_Dreieck_a); tf_Dreieck_a.setColumns(10); - + JLabel lblDreieck_b = new JLabel("b"); GridBagConstraints gbc_lblDreieck_b = new GridBagConstraints(); gbc_lblDreieck_b.anchor = GridBagConstraints.EAST; @@ -413,7 +400,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblDreieck_b.gridx = 3; gbc_lblDreieck_b.gridy = 1; panel_Dreieck_1.add(lblDreieck_b, gbc_lblDreieck_b); - + tf_Dreieck_b = new JTextField(); tf_Dreieck_b.setToolTipText("Hier musst du die Seite b eingeben."); GridBagConstraints gbc_tf_Dreieck_b = new GridBagConstraints(); @@ -423,7 +410,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Dreieck_b.gridy = 1; panel_Dreieck_1.add(tf_Dreieck_b, gbc_tf_Dreieck_b); tf_Dreieck_b.setColumns(10); - + JLabel lblNewLabel_4 = new JLabel("c"); GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints(); gbc_lblNewLabel_4.anchor = GridBagConstraints.EAST; @@ -431,7 +418,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblNewLabel_4.gridx = 5; gbc_lblNewLabel_4.gridy = 1; panel_Dreieck_1.add(lblNewLabel_4, gbc_lblNewLabel_4); - + tf_Dreieck_c = new JTextField(); tf_Dreieck_c.setToolTipText("Hier musst du die Seite c eingeben."); GridBagConstraints gbc_tf_Dreieck_c = new GridBagConstraints(); @@ -441,7 +428,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Dreieck_c.gridy = 1; panel_Dreieck_1.add(tf_Dreieck_c, gbc_tf_Dreieck_c); tf_Dreieck_c.setColumns(10); - + JLabel lblDreieck_Alpha = new JLabel("Alpha"); GridBagConstraints gbc_lblDreieck_Alpha = new GridBagConstraints(); gbc_lblDreieck_Alpha.anchor = GridBagConstraints.EAST; @@ -449,7 +436,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblDreieck_Alpha.gridx = 1; gbc_lblDreieck_Alpha.gridy = 2; panel_Dreieck_1.add(lblDreieck_Alpha, gbc_lblDreieck_Alpha); - + tf_Dreieck_alpha = new JTextField(); tf_Dreieck_alpha.setToolTipText("Hier musst du den Winkel Alpha eingeben."); GridBagConstraints gbc_tf_Dreieck_alpha = new GridBagConstraints(); @@ -459,7 +446,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Dreieck_alpha.gridy = 2; panel_Dreieck_1.add(tf_Dreieck_alpha, gbc_tf_Dreieck_alpha); tf_Dreieck_alpha.setColumns(10); - + JLabel lblDreieck_Beta = new JLabel("Beta"); GridBagConstraints gbc_lblDreieck_Beta = new GridBagConstraints(); gbc_lblDreieck_Beta.anchor = GridBagConstraints.EAST; @@ -467,7 +454,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblDreieck_Beta.gridx = 3; gbc_lblDreieck_Beta.gridy = 2; panel_Dreieck_1.add(lblDreieck_Beta, gbc_lblDreieck_Beta); - + tf_Dreieck_beta = new JTextField(); tf_Dreieck_beta.setToolTipText("Hier musst du den Winkel Beta eingeben."); GridBagConstraints gbc_tf_Dreieck_beta = new GridBagConstraints(); @@ -477,7 +464,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Dreieck_beta.gridy = 2; panel_Dreieck_1.add(tf_Dreieck_beta, gbc_tf_Dreieck_beta); tf_Dreieck_beta.setColumns(10); - + JLabel lblDreieck_Gamma = new JLabel("Gamma"); GridBagConstraints gbc_lblDreieck_Gamma = new GridBagConstraints(); gbc_lblDreieck_Gamma.anchor = GridBagConstraints.EAST; @@ -485,204 +472,236 @@ public void actionPerformed(ActionEvent e) { gbc_lblDreieck_Gamma.gridx = 5; gbc_lblDreieck_Gamma.gridy = 2; panel_Dreieck_1.add(lblDreieck_Gamma, gbc_lblDreieck_Gamma); - + // Dreieck Berechnen beginn JButton btnDreieck_calc = new JButton("Berechnen"); btnDreieck_calc.setToolTipText("Hiermit kannst du aus 3 Werten alle anderen errechnen lassen."); btnDreieck_calc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - Dreieck dreieck = new Dreieck(); - - int i = 0; - ArrayList arr = new ArrayList(); - ArrayList arr1 = new ArrayList(); - // set sides and angles - // getter - if(!tf_Dreieck_a.getText().isEmpty()) { - try { - dreieck.setSidea(Double.parseDouble(tf_Dreieck_a.getText().replaceAll(",", "."))); - i++; - arr.add("sidea"); - arr1.add(dreieck.getSidea()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Seite A\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Dreieck_b.getText().isEmpty()) { - try { - dreieck.setB(Double.parseDouble(tf_Dreieck_b.getText().replaceAll(",", "."))); - i++; - arr.add("sideb"); - arr1.add(dreieck.getB()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Seite B\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Dreieck_c.getText().isEmpty()) { - try { - dreieck.setC(Double.parseDouble(tf_Dreieck_c.getText().replaceAll(",", "."))); - i++; - arr.add("sidec"); - arr1.add(dreieck.getC()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Seite c\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Dreieck_alpha.getText().isEmpty()) { - try { - dreieck.setAlpha(Double.parseDouble(tf_Dreieck_alpha.getText().replaceAll(",", "."))); - i++; - arr.add("alpha"); - arr1.add(dreieck.getAlpha()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Alpha\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Dreieck_beta.getText().isEmpty()) { - try { - dreieck.setBeta(Double.parseDouble(tf_Dreieck_beta.getText().replaceAll(",", "."))); - i++; - arr.add("beta"); - arr1.add(dreieck.getBeta()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Beta\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Dreieck_gamma.getText().isEmpty()) { - try { - dreieck.setGamma(Double.parseDouble(tf_Dreieck_gamma.getText().replaceAll(",", "."))); - i++; - arr.add("gamma"); - arr1.add(dreieck.getGamma()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Gamma\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Dreieck_heighta.getText().isEmpty()) { - try { - dreieck.setHeighta(Double.parseDouble(tf_Dreieck_heighta.getText().replaceAll(",", "."))); - i++; - arr.add("ha"); - arr1.add(dreieck.getHeighta()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Höhe a\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Dreieck_heightb.getText().isEmpty()) { - try { - dreieck.setHeightb(Double.parseDouble(tf_Dreieck_heightb.getText().replaceAll(",", "."))); - i++; - arr.add("hb"); - arr1.add(dreieck.getHeightb()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Höhe b\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Dreieck_heightc.getText().isEmpty()) { - try { - dreieck.setHeightc(Double.parseDouble(tf_Dreieck_heightc.getText().replaceAll(",", "."))); - i++; - arr.add("hc"); - arr1.add(dreieck.getHeightc()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Höhe c\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Dreieck_Flaeche.getText().isEmpty()) { - try { - dreieck.setA(Double.parseDouble(tf_Dreieck_Flaeche.getText().replaceAll(",", "."))); - i++; - arr.add("flaeche"); - arr1.add(dreieck.getA()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Fläche\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Dreieck_Umfang.getText().isEmpty()) { - try { - dreieck.setU(Double.parseDouble(tf_Dreieck_Umfang.getText().replaceAll(",", "."))); - i++; - arr.add("umfang"); - arr1.add(dreieck.getU()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Umfang\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if (i==3) { - if (!(Datenbank.getDB(dreieck, arr, arr1))) { - //System.out.println("calc"); - dreieck.calculate(); - + Dreieck dreieck = new Dreieck(); + + int i = 0; + ArrayList arr = new ArrayList(); + ArrayList arr1 = new ArrayList(); + // set sides and angles + // getter + if (!tf_Dreieck_a.getText().isEmpty()) { + try { + dreieck.setSidea(Double.parseDouble(tf_Dreieck_a.getText().replaceAll(",", "."))); + i++; + arr.add("sidea"); + arr1.add(dreieck.getSidea()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Seite A\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (!tf_Dreieck_b.getText().isEmpty()) { + try { + dreieck.setB(Double.parseDouble(tf_Dreieck_b.getText().replaceAll(",", "."))); + i++; + arr.add("sideb"); + arr1.add(dreieck.getB()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Seite B\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (!tf_Dreieck_c.getText().isEmpty()) { + try { + dreieck.setC(Double.parseDouble(tf_Dreieck_c.getText().replaceAll(",", "."))); + i++; + arr.add("sidec"); + arr1.add(dreieck.getC()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Seite c\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (!tf_Dreieck_alpha.getText().isEmpty()) { + try { + dreieck.setAlpha(Double.parseDouble(tf_Dreieck_alpha.getText().replaceAll(",", "."))); + i++; + arr.add("alpha"); + arr1.add(dreieck.getAlpha()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Alpha\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (!tf_Dreieck_beta.getText().isEmpty()) { + try { + dreieck.setBeta(Double.parseDouble(tf_Dreieck_beta.getText().replaceAll(",", "."))); + i++; + arr.add("beta"); + arr1.add(dreieck.getBeta()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Beta\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (!tf_Dreieck_gamma.getText().isEmpty()) { + try { + dreieck.setGamma(Double.parseDouble(tf_Dreieck_gamma.getText().replaceAll(",", "."))); + i++; + arr.add("gamma"); + arr1.add(dreieck.getGamma()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Gamma\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (!tf_Dreieck_heighta.getText().isEmpty()) { + try { + dreieck.setHeighta(Double.parseDouble(tf_Dreieck_heighta.getText().replaceAll(",", "."))); + i++; + arr.add("ha"); + arr1.add(dreieck.getHeighta()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"H�he a\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (!tf_Dreieck_heightb.getText().isEmpty()) { + try { + dreieck.setHeightb(Double.parseDouble(tf_Dreieck_heightb.getText().replaceAll(",", "."))); + i++; + arr.add("hb"); + arr1.add(dreieck.getHeightb()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"H�he b\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (!tf_Dreieck_heightc.getText().isEmpty()) { + try { + dreieck.setHeightc(Double.parseDouble(tf_Dreieck_heightc.getText().replaceAll(",", "."))); + i++; + arr.add("hc"); + arr1.add(dreieck.getHeightc()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"H�he c\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (!tf_Dreieck_Flaeche.getText().isEmpty()) { + try { + dreieck.setA(Double.parseDouble(tf_Dreieck_Flaeche.getText().replaceAll(",", "."))); + i++; + arr.add("flaeche"); + arr1.add(dreieck.getA()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Fl�che\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (!tf_Dreieck_Umfang.getText().isEmpty()) { + try { + dreieck.setU(Double.parseDouble(tf_Dreieck_Umfang.getText().replaceAll(",", "."))); + i++; + arr.add("umfang"); + arr1.add(dreieck.getU()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Umfang\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (i == 3) { + if (!(Datenbank.getDB(dreieck, arr, arr1))) { + // System.out.println("calc"); + dreieck.calculate(); + + } + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte 3 Werte angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + // setter + if (dreieck.getSidea() != null && dreieck.getB() != null && dreieck.getC() != null + && dreieck.getAlpha() != null && dreieck.getBeta() != null && dreieck.getGamma() != null + && dreieck.getA() != null && dreieck.getU() != null && dreieck.getInradius() != null + && dreieck.getUmradius() != null) { + + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Dreieck nicht Konstruierbar.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + if (dreieck.getSidea() > 0 && dreieck.getB() > 0 && dreieck.getC() > 0 && dreieck.getAlpha() > 0 + && dreieck.getBeta() > 0 && dreieck.getGamma() > 0 && dreieck.getA() > 0 && dreieck.getU() > 0 + && dreieck.getInradius() > 0 && dreieck.getUmradius() > 0) { + + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Dreieck nicht Konstruierbar.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + Datenbank.save_DB(dreieck); + + if (tf_Dreieck_a.getText().isEmpty()) { + tf_Dreieck_a.setText( + String.valueOf((double) Math.round(dreieck.getSidea() * 100) / 100).replace(".", ",")); + } + if (tf_Dreieck_b.getText().isEmpty()) { + tf_Dreieck_b + .setText(String.valueOf((double) Math.round(dreieck.getB() * 100) / 100).replace(".", ",")); + } + if (tf_Dreieck_c.getText().isEmpty()) { + tf_Dreieck_c + .setText(String.valueOf((double) Math.round(dreieck.getC() * 100) / 100).replace(".", ",")); + } + if (tf_Dreieck_alpha.getText().isEmpty()) { + tf_Dreieck_alpha.setText( + String.valueOf((double) Math.round(dreieck.getAlpha() * 100) / 100).replace(".", ",")); + } + if (tf_Dreieck_beta.getText().isEmpty()) { + tf_Dreieck_beta.setText( + String.valueOf((double) Math.round(dreieck.getBeta() * 100) / 100).replace(".", ",")); + } + if (tf_Dreieck_gamma.getText().isEmpty()) { + tf_Dreieck_gamma.setText( + String.valueOf((double) Math.round(dreieck.getGamma() * 100) / 100).replace(".", ",")); + } + if (tf_Dreieck_heighta.getText().isEmpty()) { + tf_Dreieck_heighta.setText( + String.valueOf((double) Math.round(dreieck.getHeighta() * 100) / 100).replace(".", ",")); + } + if (tf_Dreieck_heightb.getText().isEmpty()) { + tf_Dreieck_heightb.setText( + String.valueOf((double) Math.round(dreieck.getHeightb() * 100) / 100).replace(".", ",")); + } + if (tf_Dreieck_heightc.getText().isEmpty()) { + tf_Dreieck_heightc.setText( + String.valueOf((double) Math.round(dreieck.getHeightc() * 100) / 100).replace(".", ",")); + } + if (tf_Dreieck_Umfang.getText().isEmpty()) { + tf_Dreieck_Umfang + .setText(String.valueOf((double) Math.round(dreieck.getU() * 100) / 100).replace(".", ",")); + } + if (tf_Dreieck_Flaeche.getText().isEmpty()) { + tf_Dreieck_Flaeche + .setText(String.valueOf((double) Math.round(dreieck.getA() * 100) / 100).replace(".", ",")); + } + lbl_Dreieck_Inradius_Ergebnis.setText( + String.valueOf((double) Math.round(dreieck.getInradius() * 100) / 100).replace(".", ",")); + lbl_Dreieck_Umradius_Ergebnis.setText( + String.valueOf((double) Math.round(dreieck.getUmradius() * 100) / 100).replace(".", ",")); + // Dreieck ende } - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte 3 Werte angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - // setter - if(dreieck.getSidea()!=null && dreieck.getB()!=null && dreieck.getC()!=null && dreieck.getAlpha()!=null && dreieck.getBeta()!=null && dreieck.getGamma()!=null && dreieck.getA()!=null && dreieck.getU()!=null && dreieck.getInradius()!=null && dreieck.getUmradius()!=null) { - - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Dreieck nicht Konstruierbar.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - if(dreieck.getSidea()>0 && dreieck.getB()>0 && dreieck.getC()>0 && dreieck.getAlpha()>0 && dreieck.getBeta()>0 && dreieck.getGamma()>0 && dreieck.getA()>0 && dreieck.getU()>0 && dreieck.getInradius()>0 && dreieck.getUmradius()>0) { - - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Dreieck nicht Konstruierbar.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - Datenbank.save_DB(dreieck); - - if(tf_Dreieck_a.getText().isEmpty()) { - tf_Dreieck_a.setText(String.valueOf((double) Math.round(dreieck.getSidea() * div) / div).replace(".", ",")); - } - if(tf_Dreieck_b.getText().isEmpty()) { - tf_Dreieck_b.setText(String.valueOf((double) Math.round(dreieck.getB() * div) / div).replace(".", ",")); - } - if(tf_Dreieck_c.getText().isEmpty()) { - tf_Dreieck_c.setText(String.valueOf((double) Math.round(dreieck.getC() * div) / div).replace(".", ",")); - } - if(tf_Dreieck_alpha.getText().isEmpty()) { - tf_Dreieck_alpha.setText(String.valueOf((double) Math.round(dreieck.getAlpha() * div) / div).replace(".", ",")); - } - if(tf_Dreieck_beta.getText().isEmpty()) { - tf_Dreieck_beta.setText(String.valueOf((double) Math.round(dreieck.getBeta() * div) / div).replace(".", ",")); - } - if(tf_Dreieck_gamma.getText().isEmpty()) { - tf_Dreieck_gamma.setText(String.valueOf((double) Math.round(dreieck.getGamma() * div) / div).replace(".", ",")); - } - if(tf_Dreieck_heighta.getText().isEmpty()) { - tf_Dreieck_heighta.setText(String.valueOf((double) Math.round(dreieck.getHeighta() * div) / div).replace(".", ",")); - } - if(tf_Dreieck_heightb.getText().isEmpty()) { - tf_Dreieck_heightb.setText(String.valueOf((double) Math.round(dreieck.getHeightb() * div) / div).replace(".", ",")); - } - if(tf_Dreieck_heightc.getText().isEmpty()) { - tf_Dreieck_heightc.setText(String.valueOf((double) Math.round(dreieck.getHeightc() * div) / div).replace(".", ",")); - } - if(tf_Dreieck_Umfang.getText().isEmpty()) { - tf_Dreieck_Umfang.setText(String.valueOf((double) Math.round(dreieck.getU()*div)/div).replace(".", ",")); - } - if(tf_Dreieck_Flaeche.getText().isEmpty()) { - tf_Dreieck_Flaeche.setText(String.valueOf((double) Math.round(dreieck.getA()*div)/div).replace(".", ",")); - } - lbl_Dreieck_Inradius_Ergebnis.setText(String.valueOf((double) Math.round(dreieck.getInradius()*div)/div).replace(".", ",")); - lbl_Dreieck_Umradius_Ergebnis.setText(String.valueOf((double) Math.round(dreieck.getUmradius()*div)/div).replace(".", ",")); - // Dreieck ende - } }); - + tf_Dreieck_gamma = new JTextField(); tf_Dreieck_gamma.setToolTipText("Hier musst du den Winkel Gamma eingeben."); GridBagConstraints gbc_tf_Dreieck_gamma = new GridBagConstraints(); @@ -692,7 +711,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Dreieck_gamma.gridy = 2; panel_Dreieck_1.add(tf_Dreieck_gamma, gbc_tf_Dreieck_gamma); tf_Dreieck_gamma.setColumns(10); - + JLabel lblHeighta = new JLabel("H\u00F6he a"); GridBagConstraints gbc_lblHeighta = new GridBagConstraints(); gbc_lblHeighta.anchor = GridBagConstraints.EAST; @@ -700,7 +719,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblHeighta.gridx = 1; gbc_lblHeighta.gridy = 3; panel_Dreieck_1.add(lblHeighta, gbc_lblHeighta); - + tf_Dreieck_heighta = new JTextField(); tf_Dreieck_heighta.setToolTipText("Hier musst du die H\u00F6he von a eingeben."); GridBagConstraints gbc_tf_Dreieck_heighta = new GridBagConstraints(); @@ -715,25 +734,25 @@ public void actionPerformed(ActionEvent e) { gbc_btnDreieck_calc.gridx = 4; gbc_btnDreieck_calc.gridy = 8; panel_Dreieck_1.add(btnDreieck_calc, gbc_btnDreieck_calc); - + JButton btnDreieck_clear = new JButton("L\u00F6schen"); btnDreieck_clear.setToolTipText("Hiermit kannst du alle Eingaben leeren."); btnDreieck_clear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - tf_Dreieck_a.setText(null); - tf_Dreieck_b.setText(null); - tf_Dreieck_c.setText(null); - tf_Dreieck_alpha.setText(null); - tf_Dreieck_beta.setText(null); - tf_Dreieck_gamma.setText(null); - tf_Dreieck_heighta.setText(null); - tf_Dreieck_heightb.setText(null); - tf_Dreieck_heightc.setText(null); - tf_Dreieck_Flaeche.setText(null); - tf_Dreieck_Umfang.setText(null); - lbl_Dreieck_Inradius_Ergebnis.setText(null); - lbl_Dreieck_Umradius_Ergebnis.setText(null); - + tf_Dreieck_a.setText(null); + tf_Dreieck_b.setText(null); + tf_Dreieck_c.setText(null); + tf_Dreieck_alpha.setText(null); + tf_Dreieck_beta.setText(null); + tf_Dreieck_gamma.setText(null); + tf_Dreieck_heighta.setText(null); + tf_Dreieck_heightb.setText(null); + tf_Dreieck_heightc.setText(null); + tf_Dreieck_Flaeche.setText(null); + tf_Dreieck_Umfang.setText(null); + lbl_Dreieck_Inradius_Ergebnis.setText(null); + lbl_Dreieck_Umradius_Ergebnis.setText(null); + } }); GridBagConstraints gbc_btnDreieck_clear = new GridBagConstraints(); @@ -742,16 +761,16 @@ public void actionPerformed(ActionEvent e) { gbc_btnDreieck_clear.gridy = 8; panel_Dreieck_1.add(btnDreieck_clear, gbc_btnDreieck_clear); GridBagLayout gbl_panel_Dreieck_Bild = new GridBagLayout(); - gbl_panel_Dreieck_Bild.columnWidths = new int[]{250, 46, 0, 0}; - gbl_panel_Dreieck_Bild.rowHeights = new int[]{14, 0, 0}; - gbl_panel_Dreieck_Bild.columnWeights = new double[]{0.0, 1.0, 1.0, Double.MIN_VALUE}; - gbl_panel_Dreieck_Bild.rowWeights = new double[]{1.0, 0.0, Double.MIN_VALUE}; + gbl_panel_Dreieck_Bild.columnWidths = new int[] { 250, 46, 0, 0 }; + gbl_panel_Dreieck_Bild.rowHeights = new int[] { 14, 0, 0 }; + gbl_panel_Dreieck_Bild.columnWeights = new double[] { 0.0, 1.0, 1.0, Double.MIN_VALUE }; + gbl_panel_Dreieck_Bild.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE }; panel_Dreieck_Bild.setLayout(gbl_panel_Dreieck_Bild); - + JLabel lbl_Dreieck_Picture = new JLabel(""); GridBagConstraints gbc_lbl_Dreieck_Picture = new GridBagConstraints(); gbc_lbl_Dreieck_Picture.insets = new Insets(30, 0, 5, 5); - // bild einfügen + // bild einf�gen try { BufferedImage image = ImageIO.read(getClass().getResourceAsStream("Dreieck.png")); lbl_Dreieck_Picture.setIcon(new ImageIcon(resizeImage(image, 250, 160))); @@ -763,24 +782,24 @@ public void actionPerformed(ActionEvent e) { gbc_lbl_Dreieck_Picture.gridy = 0; panel_Dreieck_Bild.add(lbl_Dreieck_Picture, gbc_lbl_Dreieck_Picture); layeredPane_Dreieck.setLayout(gl_layeredPane_Dreieck); - + JLayeredPane layeredPane_Kreis = new JLayeredPane(); frmGeometrie.getContentPane().add(layeredPane_Kreis, "panel_Kreis"); - + JPanel panel_Kreis_1 = new JPanel(); panel_Kreis_1.setOpaque(false); GridBagLayout gbl_panel_Kreis_1 = new GridBagLayout(); - gbl_panel_Kreis_1.columnWidths = new int[]{200, 0, 0, 25, 0, 0, 0}; - gbl_panel_Kreis_1.rowHeights = new int[]{200, 0, 0, 0, 0, 0}; - gbl_panel_Kreis_1.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; - gbl_panel_Kreis_1.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; + gbl_panel_Kreis_1.columnWidths = new int[] { 200, 0, 0, 25, 0, 0, 0 }; + gbl_panel_Kreis_1.rowHeights = new int[] { 200, 0, 0, 0, 0, 0 }; + gbl_panel_Kreis_1.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; + gbl_panel_Kreis_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; panel_Kreis_1.setLayout(gbl_panel_Kreis_1); - + JPanel panel_Kreis_Bild = new JPanel(); panel_Kreis_Bild.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); - + JLabel lblNewLabel_81 = new JLabel(""); - // bild einfügen + // bild einf�gen try { BufferedImage image = ImageIO.read(getClass().getResourceAsStream("Kreis.png")); lblNewLabel_81.setIcon(new ImageIcon(resizeImage(image, 200, 200))); @@ -790,18 +809,14 @@ public void actionPerformed(ActionEvent e) { panel_Kreis_Bild.add(lblNewLabel_81); GroupLayout gl_layeredPane_Kreis = new GroupLayout(layeredPane_Kreis); gl_layeredPane_Kreis.setHorizontalGroup( - gl_layeredPane_Kreis.createParallelGroup(Alignment.LEADING) - .addGap(0, 884, Short.MAX_VALUE) - .addComponent(panel_Kreis_1, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) - .addComponent(panel_Kreis_Bild, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) - ); + gl_layeredPane_Kreis.createParallelGroup(Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE) + .addComponent(panel_Kreis_1, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) + .addComponent(panel_Kreis_Bild, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE)); gl_layeredPane_Kreis.setVerticalGroup( - gl_layeredPane_Kreis.createParallelGroup(Alignment.LEADING) - .addGap(0, 539, Short.MAX_VALUE) - .addComponent(panel_Kreis_1, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) - .addComponent(panel_Kreis_Bild, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) - ); - + gl_layeredPane_Kreis.createParallelGroup(Alignment.LEADING).addGap(0, 539, Short.MAX_VALUE) + .addComponent(panel_Kreis_1, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) + .addComponent(panel_Kreis_Bild, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE)); + JLabel lblKreis_r = new JLabel("Radius"); GridBagConstraints gbc_lblKreis_r = new GridBagConstraints(); gbc_lblKreis_r.anchor = GridBagConstraints.EAST; @@ -809,7 +824,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblKreis_r.gridx = 1; gbc_lblKreis_r.gridy = 1; panel_Kreis_1.add(lblKreis_r, gbc_lblKreis_r); - + tf_Kreis_r = new JTextField(); GridBagConstraints gbc_tf_Kreis_r = new GridBagConstraints(); gbc_tf_Kreis_r.insets = new Insets(0, 0, 5, 5); @@ -818,7 +833,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Kreis_r.gridy = 1; panel_Kreis_1.add(tf_Kreis_r, gbc_tf_Kreis_r); tf_Kreis_r.setColumns(10); - + JLabel lblKreis_U = new JLabel("Umfang"); GridBagConstraints gbc_lblKreis_U = new GridBagConstraints(); gbc_lblKreis_U.anchor = GridBagConstraints.EAST; @@ -826,7 +841,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblKreis_U.gridx = 4; gbc_lblKreis_U.gridy = 1; panel_Kreis_1.add(lblKreis_U, gbc_lblKreis_U); - + tf_Kreis_U = new JTextField(); GridBagConstraints gbc_tf_Kreis_U = new GridBagConstraints(); gbc_tf_Kreis_U.insets = new Insets(0, 0, 5, 0); @@ -835,7 +850,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Kreis_U.gridy = 1; panel_Kreis_1.add(tf_Kreis_U, gbc_tf_Kreis_U); tf_Kreis_U.setColumns(10); - + JLabel lblKreis_d = new JLabel("Durchmesser"); GridBagConstraints gbc_lblKreis_d = new GridBagConstraints(); gbc_lblKreis_d.anchor = GridBagConstraints.EAST; @@ -843,7 +858,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblKreis_d.gridx = 1; gbc_lblKreis_d.gridy = 2; panel_Kreis_1.add(lblKreis_d, gbc_lblKreis_d); - + tf_Kreis_d = new JTextField(); GridBagConstraints gbc_tf_Kreis_d = new GridBagConstraints(); gbc_tf_Kreis_d.insets = new Insets(0, 0, 5, 5); @@ -852,7 +867,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Kreis_d.gridy = 2; panel_Kreis_1.add(tf_Kreis_d, gbc_tf_Kreis_d); tf_Kreis_d.setColumns(10); - + JLabel lblKreis_A = new JLabel("Fl\u00E4che"); GridBagConstraints gbc_lblKreis_A = new GridBagConstraints(); gbc_lblKreis_A.anchor = GridBagConstraints.EAST; @@ -860,7 +875,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblKreis_A.gridx = 4; gbc_lblKreis_A.gridy = 2; panel_Kreis_1.add(lblKreis_A, gbc_lblKreis_A); - + tf_Kreis_A = new JTextField(); GridBagConstraints gbc_tf_Kreis_A = new GridBagConstraints(); gbc_tf_Kreis_A.insets = new Insets(0, 0, 5, 0); @@ -869,101 +884,110 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Kreis_A.gridy = 2; panel_Kreis_1.add(tf_Kreis_A, gbc_tf_Kreis_A); tf_Kreis_A.setColumns(10); - + JButton btnKreis_calc = new JButton("Berechnen"); btnKreis_calc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - Kreis kreis = new Kreis(); - int i = 0; - ArrayList arr = new ArrayList(); - ArrayList arr1 = new ArrayList(); - if(!tf_Kreis_r.getText().isEmpty()) { - try { - if (Double.parseDouble(tf_Kreis_r.getText().replaceAll(",", "."))>0) { - kreis.setR(Double.parseDouble(tf_Kreis_r.getText().replaceAll(",", "."))); - i++; - arr.add("r"); - arr1.add(kreis.getR()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; + Kreis kreis = new Kreis(); + int i = 0; + ArrayList arr = new ArrayList(); + ArrayList arr1 = new ArrayList(); + if (!tf_Kreis_r.getText().isEmpty()) { + try { + if (Double.parseDouble(tf_Kreis_r.getText().replaceAll(",", ".")) > 0) { + kreis.setR(Double.parseDouble(tf_Kreis_r.getText().replaceAll(",", "."))); + i++; + arr.add("r"); + arr1.add(kreis.getR()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Radius\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Radius\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; + if (!tf_Kreis_d.getText().isEmpty()) { + try { + if (Double.parseDouble(tf_Kreis_d.getText().replaceAll(",", ".")) > 0) { + kreis.setD(Double.parseDouble(tf_Kreis_d.getText().replaceAll(",", "."))); + i++; + arr.add("d"); + arr1.add(kreis.getD()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Durchmesser\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; } - } - if(!tf_Kreis_d.getText().isEmpty()) { - try { - if (Double.parseDouble(tf_Kreis_d.getText().replaceAll(",", "."))>0) { - kreis.setD(Double.parseDouble(tf_Kreis_d.getText().replaceAll(",", "."))); - i++; - arr.add("d"); - arr1.add(kreis.getD()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Durchmesser\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; + } + if (!tf_Kreis_U.getText().isEmpty()) { + try { + if (Double.parseDouble(tf_Kreis_U.getText().replaceAll(",", ".")) > 0) { + kreis.setU(Double.parseDouble(tf_Kreis_U.getText().replaceAll(",", "."))); + i++; + arr.add("U"); + arr1.add(kreis.getU()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Umfang\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; } - } - if(!tf_Kreis_U.getText().isEmpty()) { - try { - if (Double.parseDouble(tf_Kreis_U.getText().replaceAll(",", "."))>0) { - kreis.setU(Double.parseDouble(tf_Kreis_U.getText().replaceAll(",", "."))); - i++; - arr.add("U"); - arr1.add(kreis.getU()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Umfang\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; + } + if (!tf_Kreis_A.getText().isEmpty()) { + try { + if (Double.parseDouble(tf_Kreis_A.getText().replaceAll(",", ".")) > 0) { + kreis.setA(Double.parseDouble(tf_Kreis_A.getText().replaceAll(",", "."))); + i++; + arr.add("A"); + arr1.add(kreis.getA()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Fl�che\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; } - } - if(!tf_Kreis_A.getText().isEmpty()) { - try { - if (Double.parseDouble(tf_Kreis_A.getText().replaceAll(",", "."))>0) { - kreis.setA(Double.parseDouble(tf_Kreis_A.getText().replaceAll(",", "."))); - i++; - arr.add("A"); - arr1.add(kreis.getA()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Fläche\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; + } + if (i == 1) { + if (!Datenbank.getDB(kreis, arr, arr1)) { + kreis.calculate(); + Datenbank.save_DB(kreis); } - } - if (i==1) { - if (!Datenbank.getDB(kreis, arr, arr1)) { - kreis.calculate(); - Datenbank.save_DB(kreis); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; } - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - - if(tf_Kreis_r.getText().isEmpty()) { - tf_Kreis_r.setText(String.valueOf((double) Math.round(kreis.getR() * div) / div).replace(".", ",")); - } - if(tf_Kreis_d.getText().isEmpty()) { - tf_Kreis_d.setText(String.valueOf((double) Math.round(kreis.getD() * div) / div).replace(".", ",")); - } - if(tf_Kreis_U.getText().isEmpty()) { - tf_Kreis_U.setText(String.valueOf((double) Math.round(kreis.getU() * div) / div).replace(".", ",")); - } - if(tf_Kreis_A.getText().isEmpty()) { - tf_Kreis_A.setText(String.valueOf((double) Math.round(kreis.getA() * div) / div).replace(".", ",")); - } - + + if (tf_Kreis_r.getText().isEmpty()) { + tf_Kreis_r.setText(String.valueOf((double) Math.round(kreis.getR() * 100) / 100).replace(".", ",")); + } + if (tf_Kreis_d.getText().isEmpty()) { + tf_Kreis_d.setText(String.valueOf((double) Math.round(kreis.getD() * 100) / 100).replace(".", ",")); + } + if (tf_Kreis_U.getText().isEmpty()) { + tf_Kreis_U.setText(String.valueOf((double) Math.round(kreis.getU() * 100) / 100).replace(".", ",")); + } + if (tf_Kreis_A.getText().isEmpty()) { + tf_Kreis_A.setText(String.valueOf((double) Math.round(kreis.getA() * 100) / 100).replace(".", ",")); + } + } }); GridBagConstraints gbc_btnKreis_calc = new GridBagConstraints(); @@ -971,14 +995,14 @@ public void actionPerformed(ActionEvent e) { gbc_btnKreis_calc.gridx = 2; gbc_btnKreis_calc.gridy = 4; panel_Kreis_1.add(btnKreis_calc, gbc_btnKreis_calc); - + JButton btnKreis_clear = new JButton("L\u00F6schen"); btnKreis_clear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - tf_Kreis_A.setText(null); - tf_Kreis_d.setText(null); - tf_Kreis_r.setText(null); - tf_Kreis_U.setText(null); + tf_Kreis_A.setText(null); + tf_Kreis_d.setText(null); + tf_Kreis_r.setText(null); + tf_Kreis_U.setText(null); } }); GridBagConstraints gbc_btnKreis_clear = new GridBagConstraints(); @@ -986,23 +1010,23 @@ public void actionPerformed(ActionEvent e) { gbc_btnKreis_clear.gridy = 4; panel_Kreis_1.add(btnKreis_clear, gbc_btnKreis_clear); layeredPane_Kreis.setLayout(gl_layeredPane_Kreis); - + JLayeredPane layeredPane_Rechteck = new JLayeredPane(); frmGeometrie.getContentPane().add(layeredPane_Rechteck, "panel_Rechteck"); - + JPanel panel_Rechteck_1 = new JPanel(); panel_Rechteck_1.setOpaque(false); GridBagLayout gbl_panel_Rechteck_1 = new GridBagLayout(); - gbl_panel_Rechteck_1.columnWidths = new int[]{170, 0, 0, 0, 0, 0, 0, 0, 0}; - gbl_panel_Rechteck_1.rowHeights = new int[]{200, 0, 0, 0, 0, 0, 0, 0}; - gbl_panel_Rechteck_1.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; - gbl_panel_Rechteck_1.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; + gbl_panel_Rechteck_1.columnWidths = new int[] { 170, 0, 0, 0, 0, 0, 0, 0, 0 }; + gbl_panel_Rechteck_1.rowHeights = new int[] { 200, 0, 0, 0, 0, 0, 0, 0 }; + gbl_panel_Rechteck_1.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; + gbl_panel_Rechteck_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; panel_Rechteck_1.setLayout(gbl_panel_Rechteck_1); - + JPanel panel_Rechteck_Bild = new JPanel(); - + JLabel lblNewLabel_8_1 = new JLabel(""); - // bild einfügen + // bild einf�gen try { BufferedImage image = ImageIO.read(getClass().getResourceAsStream("Rechteck.png")); lblNewLabel_8_1.setIcon(new ImageIcon(resizeImage(image, 356, 190))); @@ -1012,19 +1036,15 @@ public void actionPerformed(ActionEvent e) { panel_Rechteck_Bild.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); panel_Rechteck_Bild.add(lblNewLabel_8_1); GroupLayout gl_layeredPane_Rechteck = new GroupLayout(layeredPane_Rechteck); - gl_layeredPane_Rechteck.setHorizontalGroup( - gl_layeredPane_Rechteck.createParallelGroup(Alignment.LEADING) + gl_layeredPane_Rechteck.setHorizontalGroup(gl_layeredPane_Rechteck.createParallelGroup(Alignment.LEADING) .addGap(0, 884, Short.MAX_VALUE) .addComponent(panel_Rechteck_1, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) - .addComponent(panel_Rechteck_Bild, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) - ); - gl_layeredPane_Rechteck.setVerticalGroup( - gl_layeredPane_Rechteck.createParallelGroup(Alignment.LEADING) + .addComponent(panel_Rechteck_Bild, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE)); + gl_layeredPane_Rechteck.setVerticalGroup(gl_layeredPane_Rechteck.createParallelGroup(Alignment.LEADING) .addGap(0, 539, Short.MAX_VALUE) .addComponent(panel_Rechteck_1, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) - .addComponent(panel_Rechteck_Bild, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) - ); - + .addComponent(panel_Rechteck_Bild, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE)); + JLabel lblRechteck_sidea = new JLabel("Seite A"); GridBagConstraints gbc_lblRechteck_sidea = new GridBagConstraints(); gbc_lblRechteck_sidea.anchor = GridBagConstraints.EAST; @@ -1032,7 +1052,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblRechteck_sidea.gridx = 2; gbc_lblRechteck_sidea.gridy = 2; panel_Rechteck_1.add(lblRechteck_sidea, gbc_lblRechteck_sidea); - + tf_Rechteck_sidea = new JTextField(); GridBagConstraints gbc_tf_Rechteck_sidea = new GridBagConstraints(); gbc_tf_Rechteck_sidea.insets = new Insets(0, 0, 5, 5); @@ -1041,7 +1061,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Rechteck_sidea.gridy = 2; panel_Rechteck_1.add(tf_Rechteck_sidea, gbc_tf_Rechteck_sidea); tf_Rechteck_sidea.setColumns(10); - + JLabel lblRechteck_sideb = new JLabel("Seite B"); GridBagConstraints gbc_lblRechteck_sideb = new GridBagConstraints(); gbc_lblRechteck_sideb.anchor = GridBagConstraints.EAST; @@ -1049,7 +1069,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblRechteck_sideb.gridx = 4; gbc_lblRechteck_sideb.gridy = 2; panel_Rechteck_1.add(lblRechteck_sideb, gbc_lblRechteck_sideb); - + tf_Rechteck_sideb = new JTextField(); GridBagConstraints gbc_tf_Rechteck_sideb = new GridBagConstraints(); gbc_tf_Rechteck_sideb.insets = new Insets(0, 0, 5, 5); @@ -1058,7 +1078,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Rechteck_sideb.gridy = 2; panel_Rechteck_1.add(tf_Rechteck_sideb, gbc_tf_Rechteck_sideb); tf_Rechteck_sideb.setColumns(10); - + JLabel lblRechteck_diag = new JLabel("Diagonale"); GridBagConstraints gbc_lblRechteck_diag = new GridBagConstraints(); gbc_lblRechteck_diag.anchor = GridBagConstraints.EAST; @@ -1066,7 +1086,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblRechteck_diag.gridx = 6; gbc_lblRechteck_diag.gridy = 2; panel_Rechteck_1.add(lblRechteck_diag, gbc_lblRechteck_diag); - + tf_Rechteck_diag = new JTextField(); GridBagConstraints gbc_tf_Rechteck_diag = new GridBagConstraints(); gbc_tf_Rechteck_diag.insets = new Insets(0, 0, 5, 0); @@ -1075,7 +1095,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Rechteck_diag.gridy = 2; panel_Rechteck_1.add(tf_Rechteck_diag, gbc_tf_Rechteck_diag); tf_Rechteck_diag.setColumns(10); - + JLabel lblRechteck_Flaeche = new JLabel("Fl\u00E4che"); GridBagConstraints gbc_lblRechteck_Flaeche = new GridBagConstraints(); gbc_lblRechteck_Flaeche.anchor = GridBagConstraints.EAST; @@ -1083,7 +1103,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblRechteck_Flaeche.gridx = 2; gbc_lblRechteck_Flaeche.gridy = 3; panel_Rechteck_1.add(lblRechteck_Flaeche, gbc_lblRechteck_Flaeche); - + tf_Rechteck_flaeche = new JTextField(); GridBagConstraints gbc_tf_Rechteck_flaeche = new GridBagConstraints(); gbc_tf_Rechteck_flaeche.insets = new Insets(0, 0, 5, 5); @@ -1092,7 +1112,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Rechteck_flaeche.gridy = 3; panel_Rechteck_1.add(tf_Rechteck_flaeche, gbc_tf_Rechteck_flaeche); tf_Rechteck_flaeche.setColumns(10); - + JLabel lblRechteck_U = new JLabel("Umfang"); GridBagConstraints gbc_lblRechteck_U = new GridBagConstraints(); gbc_lblRechteck_U.anchor = GridBagConstraints.EAST; @@ -1100,7 +1120,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblRechteck_U.gridx = 4; gbc_lblRechteck_U.gridy = 3; panel_Rechteck_1.add(lblRechteck_U, gbc_lblRechteck_U); - + tf_Rechteck_umfang = new JTextField(); GridBagConstraints gbc_tf_Rechteck_umfang = new GridBagConstraints(); gbc_tf_Rechteck_umfang.insets = new Insets(0, 0, 5, 5); @@ -1109,7 +1129,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Rechteck_umfang.gridy = 3; panel_Rechteck_1.add(tf_Rechteck_umfang, gbc_tf_Rechteck_umfang); tf_Rechteck_umfang.setColumns(10); - + JLabel lblRechteck_delta = new JLabel("Delta"); GridBagConstraints gbc_lblRechteck_delta = new GridBagConstraints(); gbc_lblRechteck_delta.anchor = GridBagConstraints.EAST; @@ -1117,7 +1137,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblRechteck_delta.gridx = 6; gbc_lblRechteck_delta.gridy = 3; panel_Rechteck_1.add(lblRechteck_delta, gbc_lblRechteck_delta); - + tf_Rechteck_delta = new JTextField(); GridBagConstraints gbc_tf_Rechteck_delta = new GridBagConstraints(); gbc_tf_Rechteck_delta.insets = new Insets(0, 0, 5, 0); @@ -1126,7 +1146,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Rechteck_delta.gridy = 3; panel_Rechteck_1.add(tf_Rechteck_delta, gbc_tf_Rechteck_delta); tf_Rechteck_delta.setColumns(10); - + JLabel lblRechteck_alpha = new JLabel("Alpha"); GridBagConstraints gbc_lblRechteck_alpha = new GridBagConstraints(); gbc_lblRechteck_alpha.anchor = GridBagConstraints.EAST; @@ -1134,7 +1154,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblRechteck_alpha.gridx = 2; gbc_lblRechteck_alpha.gridy = 4; panel_Rechteck_1.add(lblRechteck_alpha, gbc_lblRechteck_alpha); - + tf_Rechteck_alpha = new JTextField(); GridBagConstraints gbc_tf_Rechteck_alpha = new GridBagConstraints(); gbc_tf_Rechteck_alpha.insets = new Insets(0, 0, 5, 5); @@ -1143,7 +1163,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Rechteck_alpha.gridy = 4; panel_Rechteck_1.add(tf_Rechteck_alpha, gbc_tf_Rechteck_alpha); tf_Rechteck_alpha.setColumns(10); - + JLabel lblRechteck_beta = new JLabel("Beta"); GridBagConstraints gbc_lblRechteck_beta = new GridBagConstraints(); gbc_lblRechteck_beta.anchor = GridBagConstraints.EAST; @@ -1151,7 +1171,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblRechteck_beta.gridx = 4; gbc_lblRechteck_beta.gridy = 4; panel_Rechteck_1.add(lblRechteck_beta, gbc_lblRechteck_beta); - + tf_Rechteck_beta = new JTextField(); GridBagConstraints gbc_tf_Rechteck_beta = new GridBagConstraints(); gbc_tf_Rechteck_beta.insets = new Insets(0, 0, 5, 5); @@ -1160,7 +1180,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Rechteck_beta.gridy = 4; panel_Rechteck_1.add(tf_Rechteck_beta, gbc_tf_Rechteck_beta); tf_Rechteck_beta.setColumns(10); - + JLabel lblRechteck_gamma = new JLabel("Gamma"); GridBagConstraints gbc_lblRechteck_gamma = new GridBagConstraints(); gbc_lblRechteck_gamma.anchor = GridBagConstraints.EAST; @@ -1168,7 +1188,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblRechteck_gamma.gridx = 6; gbc_lblRechteck_gamma.gridy = 4; panel_Rechteck_1.add(lblRechteck_gamma, gbc_lblRechteck_gamma); - + tf_Rechteck_gamma = new JTextField(); GridBagConstraints gbc_tf_Rechteck_gamma = new GridBagConstraints(); gbc_tf_Rechteck_gamma.insets = new Insets(0, 0, 5, 0); @@ -1177,7 +1197,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Rechteck_gamma.gridy = 4; panel_Rechteck_1.add(tf_Rechteck_gamma, gbc_tf_Rechteck_gamma); tf_Rechteck_gamma.setColumns(10); - + JButton btnRechteck_calc = new JButton("Berechnen"); btnRechteck_calc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1185,240 +1205,276 @@ public void actionPerformed(ActionEvent e) { int i = 0; ArrayList arr = new ArrayList(); ArrayList arr1 = new ArrayList(); - if(!tf_Rechteck_alpha.getText().isEmpty()) { + if (!tf_Rechteck_alpha.getText().isEmpty()) { try { - if (Double.parseDouble(tf_Rechteck_alpha.getText().replaceAll(",", "."))>0) { - rechteck.setAlpha(Double.parseDouble(tf_Rechteck_alpha.getText().replaceAll(",", "."))); - i++; - arr.add("alpha"); - arr1.add(rechteck.getAlpha()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + if (Double.parseDouble(tf_Rechteck_alpha.getText().replaceAll(",", ".")) > 0) { + rechteck.setAlpha(Double.parseDouble(tf_Rechteck_alpha.getText().replaceAll(",", "."))); + i++; + arr.add("alpha"); + arr1.add(rechteck.getAlpha()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Alpha\" ", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Alpha\" ", "Error", + JOptionPane.ERROR_MESSAGE); return; - } + } } - if(!tf_Rechteck_beta.getText().isEmpty()) { + if (!tf_Rechteck_beta.getText().isEmpty()) { try { - if (Double.parseDouble(tf_Rechteck_beta.getText().replaceAll(",", "."))>0) { - rechteck.setBeta(Double.parseDouble(tf_Rechteck_beta.getText().replaceAll(",", "."))); - i++; - arr.add("beta"); - arr1.add(rechteck.getBeta()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + if (Double.parseDouble(tf_Rechteck_beta.getText().replaceAll(",", ".")) > 0) { + rechteck.setBeta(Double.parseDouble(tf_Rechteck_beta.getText().replaceAll(",", "."))); + i++; + arr.add("beta"); + arr1.add(rechteck.getBeta()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Beta\" ", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Beta\" ", "Error", + JOptionPane.ERROR_MESSAGE); return; - } + } } - if(!tf_Rechteck_gamma.getText().isEmpty()) { + if (!tf_Rechteck_gamma.getText().isEmpty()) { try { - if (Double.parseDouble(tf_Rechteck_gamma.getText().replaceAll(",", "."))>0) { - rechteck.setGamma(Double.parseDouble(tf_Rechteck_gamma.getText().replaceAll(",", "."))); - i++; - arr.add("gamma"); - arr1.add(rechteck.getGamma()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + if (Double.parseDouble(tf_Rechteck_gamma.getText().replaceAll(",", ".")) > 0) { + rechteck.setGamma(Double.parseDouble(tf_Rechteck_gamma.getText().replaceAll(",", "."))); + i++; + arr.add("gamma"); + arr1.add(rechteck.getGamma()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Gamma\" ", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Gamma\" ", "Error", + JOptionPane.ERROR_MESSAGE); return; - } + } } - if(!tf_Rechteck_delta.getText().isEmpty()) { + if (!tf_Rechteck_delta.getText().isEmpty()) { try { - if (Double.parseDouble(tf_Rechteck_delta.getText().replaceAll(",", "."))>0) { - rechteck.setDelta(Double.parseDouble(tf_Rechteck_delta.getText().replaceAll(",", "."))); - i++; - arr.add("delta"); - arr1.add(rechteck.getDelta()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + if (Double.parseDouble(tf_Rechteck_delta.getText().replaceAll(",", ".")) > 0) { + rechteck.setDelta(Double.parseDouble(tf_Rechteck_delta.getText().replaceAll(",", "."))); + i++; + arr.add("delta"); + arr1.add(rechteck.getDelta()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Delta\" ", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Delta\" ", "Error", + JOptionPane.ERROR_MESSAGE); return; - } + } } - if(!tf_Rechteck_sidea.getText().isEmpty()) { + if (!tf_Rechteck_sidea.getText().isEmpty()) { try { - if (Double.parseDouble(tf_Rechteck_sidea.getText().replaceAll(",", "."))>0) { - rechteck.setSidea(Double.parseDouble(tf_Rechteck_sidea.getText().replaceAll(",", "."))); - i++; - arr.add("sidea"); - arr1.add(rechteck.getSidea()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + if (Double.parseDouble(tf_Rechteck_sidea.getText().replaceAll(",", ".")) > 0) { + rechteck.setSidea(Double.parseDouble(tf_Rechteck_sidea.getText().replaceAll(",", "."))); + i++; + arr.add("sidea"); + arr1.add(rechteck.getSidea()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Seite A\" ", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Seite A\" ", "Error", + JOptionPane.ERROR_MESSAGE); return; - } + } } - if(!tf_Rechteck_sideb.getText().isEmpty()) { + if (!tf_Rechteck_sideb.getText().isEmpty()) { try { - if (Double.parseDouble(tf_Rechteck_sideb.getText().replaceAll(",", "."))>0) { - rechteck.setSideb(Double.parseDouble(tf_Rechteck_sideb.getText().replaceAll(",", "."))); - i++; - arr.add("sideb"); - arr1.add(rechteck.getSideb()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + if (Double.parseDouble(tf_Rechteck_sideb.getText().replaceAll(",", ".")) > 0) { + rechteck.setSideb(Double.parseDouble(tf_Rechteck_sideb.getText().replaceAll(",", "."))); + i++; + arr.add("sideb"); + arr1.add(rechteck.getSideb()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Seite B\" ", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Seite B\" ", "Error", + JOptionPane.ERROR_MESSAGE); return; - } + } } - if(!tf_Rechteck_umfang.getText().isEmpty()) { + if (!tf_Rechteck_umfang.getText().isEmpty()) { try { - if (Double.parseDouble(tf_Rechteck_umfang.getText().replaceAll(",", "."))>0) { - rechteck.setU(Double.parseDouble(tf_Rechteck_umfang.getText().replaceAll(",", "."))); - i++; - arr.add("umfang"); - arr1.add(rechteck.getU()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + if (Double.parseDouble(tf_Rechteck_umfang.getText().replaceAll(",", ".")) > 0) { + rechteck.setU(Double.parseDouble(tf_Rechteck_umfang.getText().replaceAll(",", "."))); + i++; + arr.add("umfang"); + arr1.add(rechteck.getU()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Umfang\" ", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Umfang\" ", "Error", + JOptionPane.ERROR_MESSAGE); return; - } - + } + } - if(!tf_Rechteck_flaeche.getText().isEmpty()) { + if (!tf_Rechteck_flaeche.getText().isEmpty()) { try { - if (Double.parseDouble(tf_Rechteck_flaeche.getText().replaceAll(",", "."))>0) { - rechteck.setA(Double.parseDouble(tf_Rechteck_flaeche.getText().replaceAll(",", "."))); - i++; - arr.add("flaeche"); - arr1.add(rechteck.getA()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + if (Double.parseDouble(tf_Rechteck_flaeche.getText().replaceAll(",", ".")) > 0) { + rechteck.setA(Double.parseDouble(tf_Rechteck_flaeche.getText().replaceAll(",", "."))); + i++; + arr.add("flaeche"); + arr1.add(rechteck.getA()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Fläche\" ", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Fl�che\" ", "Error", + JOptionPane.ERROR_MESSAGE); return; - } + } } - if(!tf_Rechteck_diag.getText().isEmpty()) { + if (!tf_Rechteck_diag.getText().isEmpty()) { try { - if (Double.parseDouble(tf_Rechteck_diag.getText().replaceAll(",", "."))>0) { - rechteck.setD(Double.parseDouble(tf_Rechteck_diag.getText().replaceAll(",", "."))); - - i++; - arr.add("d"); - arr1.add(rechteck.getD()); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + if (Double.parseDouble(tf_Rechteck_diag.getText().replaceAll(",", ".")) > 0) { + rechteck.setD(Double.parseDouble(tf_Rechteck_diag.getText().replaceAll(",", "."))); + + i++; + arr.add("d"); + arr1.add(rechteck.getD()); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Positiven Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Diagonale\" ", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Diagonale\" ", "Error", + JOptionPane.ERROR_MESSAGE); return; - } + } } if (i == 2) { if (!Datenbank.getDB(rechteck, arr, arr1)) { rechteck.calculate(); - + } } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte 2 Werte angeben.", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Bitte 2 Werte angeben.", "Error", + JOptionPane.ERROR_MESSAGE); arr.clear(); arr1.clear(); return; } if (rechteck.getAlpha() != null && rechteck.getAlpha() > 0.0) { - Datenbank.save_DB(rechteck); + Datenbank.save_DB(rechteck); } else { - JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", + JOptionPane.ERROR_MESSAGE); return; } - if(tf_Rechteck_alpha.getText().isEmpty()) { - - - tf_Rechteck_alpha.setText(String.valueOf((double) Math.round(rechteck.getAlpha() * div) / div).replace(".", ",")); - + if (tf_Rechteck_alpha.getText().isEmpty()) { + + tf_Rechteck_alpha.setText( + String.valueOf((double) Math.round(rechteck.getAlpha() * 100) / 100).replace(".", ",")); + } - if(tf_Rechteck_beta.getText().isEmpty()) { + if (tf_Rechteck_beta.getText().isEmpty()) { if (rechteck.getBeta() != null) { - tf_Rechteck_beta.setText(String.valueOf((double) Math.round(rechteck.getBeta() * div) / div).replace(".", ",")); + tf_Rechteck_beta.setText( + String.valueOf((double) Math.round(rechteck.getBeta() * 100) / 100).replace(".", ",")); } else { - JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", + JOptionPane.ERROR_MESSAGE); return; } - } - if(tf_Rechteck_gamma.getText().isEmpty()) { + } + if (tf_Rechteck_gamma.getText().isEmpty()) { if (rechteck.getGamma() != null) { - tf_Rechteck_gamma.setText(String.valueOf((double) Math.round(rechteck.getGamma() * div) / div).replace(".", ",")); + tf_Rechteck_gamma.setText( + String.valueOf((double) Math.round(rechteck.getGamma() * 100) / 100).replace(".", ",")); } else { - JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", + JOptionPane.ERROR_MESSAGE); return; } } - if(tf_Rechteck_delta.getText().isEmpty()) { - if (rechteck.getDelta() != null) { - tf_Rechteck_delta.setText(String.valueOf((double) Math.round(rechteck.getDelta() * div) / div).replace(".", ",")); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + if (tf_Rechteck_delta.getText().isEmpty()) { + if (rechteck.getDelta() != null) { + tf_Rechteck_delta.setText( + String.valueOf((double) Math.round(rechteck.getDelta() * 100) / 100).replace(".", ",")); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } - if(tf_Rechteck_sidea.getText().isEmpty()) { + if (tf_Rechteck_sidea.getText().isEmpty()) { if (rechteck.getSidea() != null) { - tf_Rechteck_sidea.setText(String.valueOf((double) Math.round(rechteck.getSidea() * div) / div).replace(".", ",")); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + tf_Rechteck_sidea.setText( + String.valueOf((double) Math.round(rechteck.getSidea() * 100) / 100).replace(".", ",")); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } - if(tf_Rechteck_sideb.getText().isEmpty()) { + if (tf_Rechteck_sideb.getText().isEmpty()) { if (rechteck.getSideb() != null) { - tf_Rechteck_sideb.setText(String.valueOf((double) Math.round(rechteck.getSideb() * div) / div).replace(".", ",")); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + tf_Rechteck_sideb.setText( + String.valueOf((double) Math.round(rechteck.getSideb() * 100) / 100).replace(".", ",")); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } - if(tf_Rechteck_umfang.getText().isEmpty()) { + if (tf_Rechteck_umfang.getText().isEmpty()) { if (rechteck.getU() != null) { - tf_Rechteck_umfang.setText(String.valueOf((double) Math.round(rechteck.getU() * div) / div).replace(".", ",")); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + tf_Rechteck_umfang.setText( + String.valueOf((double) Math.round(rechteck.getU() * 100) / 100).replace(".", ",")); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } - if(tf_Rechteck_flaeche.getText().isEmpty()) { + if (tf_Rechteck_flaeche.getText().isEmpty()) { if (rechteck.getA() != null) { - tf_Rechteck_flaeche.setText(String.valueOf((double) Math.round(rechteck.getA() * div) / div).replace(".", ",")); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + tf_Rechteck_flaeche.setText( + String.valueOf((double) Math.round(rechteck.getA() * 100) / 100).replace(".", ",")); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } - if(tf_Rechteck_diag.getText().isEmpty()) { + if (tf_Rechteck_diag.getText().isEmpty()) { if (rechteck.getD() != null) { - tf_Rechteck_diag.setText(String.valueOf((double) Math.round(rechteck.getD() * div) / div).replace(".", ",")); - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", JOptionPane.ERROR_MESSAGE); - return; - } + tf_Rechteck_diag.setText( + String.valueOf((double) Math.round(rechteck.getD() * 100) / 100).replace(".", ",")); + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Rechteck ist nicht Konstruierbar!", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } - + } }); GridBagConstraints gbc_btnRechteck_calc = new GridBagConstraints(); @@ -1426,7 +1482,7 @@ public void actionPerformed(ActionEvent e) { gbc_btnRechteck_calc.gridx = 4; gbc_btnRechteck_calc.gridy = 6; panel_Rechteck_1.add(btnRechteck_calc, gbc_btnRechteck_calc); - + JButton btnRechteck_clear = new JButton("L\u00F6schen"); btnRechteck_clear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1447,23 +1503,23 @@ public void actionPerformed(ActionEvent e) { gbc_btnRechteck_clear.gridy = 6; panel_Rechteck_1.add(btnRechteck_clear, gbc_btnRechteck_clear); layeredPane_Rechteck.setLayout(gl_layeredPane_Rechteck); - + JLayeredPane layeredPane_Quadrat = new JLayeredPane(); frmGeometrie.getContentPane().add(layeredPane_Quadrat, "panel_Quadrat"); - + JPanel panel_Quadrat_1 = new JPanel(); panel_Quadrat_1.setOpaque(false); GridBagLayout gbl_panel_Quadrat_1 = new GridBagLayout(); - gbl_panel_Quadrat_1.columnWidths = new int[]{250, 0, 0, 0, 0, 0, 0, 0, 0}; - gbl_panel_Quadrat_1.rowHeights = new int[]{300, 0, 0, 0, 0, 0, 0, 0}; - gbl_panel_Quadrat_1.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; - gbl_panel_Quadrat_1.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; + gbl_panel_Quadrat_1.columnWidths = new int[] { 250, 0, 0, 0, 0, 0, 0, 0, 0 }; + gbl_panel_Quadrat_1.rowHeights = new int[] { 300, 0, 0, 0, 0, 0, 0, 0 }; + gbl_panel_Quadrat_1.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; + gbl_panel_Quadrat_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; panel_Quadrat_1.setLayout(gbl_panel_Quadrat_1); - + JPanel panel_Quadrat_Bild = new JPanel(); - + JLabel lblNewLabel_8_2 = new JLabel(""); - // bild einfügen + // bild einf�gen try { BufferedImage image = ImageIO.read(getClass().getResourceAsStream("Quadrat.png")); lblNewLabel_8_2.setIcon(new ImageIcon(resizeImage(image, 295, 284))); @@ -1474,18 +1530,14 @@ public void actionPerformed(ActionEvent e) { panel_Quadrat_Bild.add(lblNewLabel_8_2); GroupLayout gl_layeredPane_Quadrat = new GroupLayout(layeredPane_Quadrat); gl_layeredPane_Quadrat.setHorizontalGroup( - gl_layeredPane_Quadrat.createParallelGroup(Alignment.LEADING) - .addGap(0, 884, Short.MAX_VALUE) - .addComponent(panel_Quadrat_1, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) - .addComponent(panel_Quadrat_Bild, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) - ); + gl_layeredPane_Quadrat.createParallelGroup(Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE) + .addComponent(panel_Quadrat_1, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE) + .addComponent(panel_Quadrat_Bild, GroupLayout.PREFERRED_SIZE, 884, GroupLayout.PREFERRED_SIZE)); gl_layeredPane_Quadrat.setVerticalGroup( - gl_layeredPane_Quadrat.createParallelGroup(Alignment.LEADING) - .addGap(0, 539, Short.MAX_VALUE) - .addComponent(panel_Quadrat_1, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) - .addComponent(panel_Quadrat_Bild, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) - ); - + gl_layeredPane_Quadrat.createParallelGroup(Alignment.LEADING).addGap(0, 539, Short.MAX_VALUE) + .addComponent(panel_Quadrat_1, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE) + .addComponent(panel_Quadrat_Bild, GroupLayout.PREFERRED_SIZE, 539, GroupLayout.PREFERRED_SIZE)); + JLabel lblQuadrat_sidea = new JLabel("Seite A"); GridBagConstraints gbc_lblQuadrat_sidea = new GridBagConstraints(); gbc_lblQuadrat_sidea.anchor = GridBagConstraints.EAST; @@ -1493,7 +1545,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblQuadrat_sidea.gridx = 4; gbc_lblQuadrat_sidea.gridy = 3; panel_Quadrat_1.add(lblQuadrat_sidea, gbc_lblQuadrat_sidea); - + tf_Quadrat_sidea = new JTextField(); GridBagConstraints gbc_tf_Quadrat_sidea = new GridBagConstraints(); gbc_tf_Quadrat_sidea.insets = new Insets(0, 0, 5, 5); @@ -1502,7 +1554,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Quadrat_sidea.gridy = 3; panel_Quadrat_1.add(tf_Quadrat_sidea, gbc_tf_Quadrat_sidea); tf_Quadrat_sidea.setColumns(10); - + JLabel lblQuadrat_A = new JLabel("Fl\u00E4che"); GridBagConstraints gbc_lblQuadrat_A = new GridBagConstraints(); gbc_lblQuadrat_A.anchor = GridBagConstraints.EAST; @@ -1510,7 +1562,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblQuadrat_A.gridx = 6; gbc_lblQuadrat_A.gridy = 3; panel_Quadrat_1.add(lblQuadrat_A, gbc_lblQuadrat_A); - + tf_Quadrat_A = new JTextField(); GridBagConstraints gbc_tf_Quadrat_A = new GridBagConstraints(); gbc_tf_Quadrat_A.insets = new Insets(0, 0, 5, 0); @@ -1519,7 +1571,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Quadrat_A.gridy = 3; panel_Quadrat_1.add(tf_Quadrat_A, gbc_tf_Quadrat_A); tf_Quadrat_A.setColumns(10); - + JLabel lblQuadrat_Umfang = new JLabel("Umfang"); GridBagConstraints gbc_lblQuadrat_Umfang = new GridBagConstraints(); gbc_lblQuadrat_Umfang.anchor = GridBagConstraints.EAST; @@ -1527,7 +1579,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblQuadrat_Umfang.gridx = 4; gbc_lblQuadrat_Umfang.gridy = 4; panel_Quadrat_1.add(lblQuadrat_Umfang, gbc_lblQuadrat_Umfang); - + tf_Quadrat_U = new JTextField(); GridBagConstraints gbc_tf_Quadrat_U = new GridBagConstraints(); gbc_tf_Quadrat_U.insets = new Insets(0, 0, 5, 5); @@ -1536,7 +1588,7 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Quadrat_U.gridy = 4; panel_Quadrat_1.add(tf_Quadrat_U, gbc_tf_Quadrat_U); tf_Quadrat_U.setColumns(10); - + JLabel lblQuadrat_Diagonale = new JLabel("Diagonale"); GridBagConstraints gbc_lblQuadrat_Diagonale = new GridBagConstraints(); gbc_lblQuadrat_Diagonale.anchor = GridBagConstraints.EAST; @@ -1544,7 +1596,7 @@ public void actionPerformed(ActionEvent e) { gbc_lblQuadrat_Diagonale.gridx = 6; gbc_lblQuadrat_Diagonale.gridy = 4; panel_Quadrat_1.add(lblQuadrat_Diagonale, gbc_lblQuadrat_Diagonale); - + tf_Quadrat_diag = new JTextField(); GridBagConstraints gbc_tf_Quadrat_diag = new GridBagConstraints(); gbc_tf_Quadrat_diag.insets = new Insets(0, 0, 5, 0); @@ -1553,84 +1605,98 @@ public void actionPerformed(ActionEvent e) { gbc_tf_Quadrat_diag.gridy = 4; panel_Quadrat_1.add(tf_Quadrat_diag, gbc_tf_Quadrat_diag); tf_Quadrat_diag.setColumns(10); - + JButton btnQuadrat_calc = new JButton("Berechnen"); btnQuadrat_calc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - Quadrat quadrat1 = new Quadrat(); - Figur quadrat = quadrat1; - int i = 0; - ArrayList arr = new ArrayList(); - ArrayList arr1 = new ArrayList(); - if(!tf_Quadrat_sidea.getText().isEmpty()) { - try { - ((Quadrat) quadrat).setSidea(Double.parseDouble(tf_Quadrat_sidea.getText().replaceAll(",", "."))); - i++; - arr.add("sidea"); - arr1.add(((Quadrat) quadrat).getSidea()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Seite A\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Quadrat_diag.getText().isEmpty()) { - try { - ((Quadrat) quadrat).setD(Double.parseDouble(tf_Quadrat_diag.getText().replaceAll(",", "."))); - i++; - arr.add("A"); - arr1.add(quadrat.getA()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Diagonale\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Quadrat_A.getText().isEmpty()) { - try { - quadrat.setA(Double.parseDouble(tf_Quadrat_A.getText().replaceAll(",", "."))); - i++; - arr.add("U"); - arr1.add(quadrat.getU()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Seite A\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if(!tf_Quadrat_U.getText().isEmpty()) { - try { - quadrat.setU(Double.parseDouble(tf_Quadrat_U.getText().replaceAll(",", "."))); - i++; - arr.add("diag"); - arr1.add(((Quadrat) quadrat).getD()); - } catch (NumberFormatException e1) { - JOptionPane.showMessageDialog(frmGeometrie, "Ungültiger Wert \"Umfang\" ", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - if (i==1) { - if (!Datenbank.getDB(quadrat, arr, arr1)) { - quadrat1.calculate(); + Quadrat quadrat1 = new Quadrat(); + Figur quadrat = quadrat1; + int i = 0; + ArrayList arr = new ArrayList(); + ArrayList arr1 = new ArrayList(); + if (!tf_Quadrat_sidea.getText().isEmpty()) { + try { + ((Quadrat) quadrat) + .setSidea(Double.parseDouble(tf_Quadrat_sidea.getText().replaceAll(",", "."))); + i++; + arr.add("sidea"); + arr1.add(((Quadrat) quadrat).getSidea()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Seite A\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Wert angeben.", "Error", JOptionPane.ERROR_MESSAGE); - return; - } - if (((Quadrat) quadrat).getSidea() != null && (((Quadrat) quadrat).getSidea() > 0) && ((Quadrat) quadrat).getD()!=null && ((Quadrat) quadrat).getD()>0) { - Datenbank.save_DB(quadrat); - if(tf_Quadrat_sidea.getText().isEmpty()) { - tf_Quadrat_sidea.setText(String.valueOf((double) Math.round(((Quadrat) quadrat).getSidea() * div) / div).replace(".", ",")); - } - if(tf_Quadrat_diag.getText().isEmpty()) { - tf_Quadrat_diag.setText(String.valueOf((double) Math.round(((Quadrat) quadrat).getD() * div) / div).replace(".", ",")); + if (!tf_Quadrat_diag.getText().isEmpty()) { + try { + ((Quadrat) quadrat).setD(Double.parseDouble(tf_Quadrat_diag.getText().replaceAll(",", "."))); + i++; + arr.add("A"); + arr1.add(quadrat.getA()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Diagonale\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } - if(tf_Quadrat_A.getText().isEmpty()) { - tf_Quadrat_A.setText(String.valueOf((double) Math.round(quadrat.getA() * div) / div).replace(".", ",")); + if (!tf_Quadrat_A.getText().isEmpty()) { + try { + quadrat.setA(Double.parseDouble(tf_Quadrat_A.getText().replaceAll(",", "."))); + i++; + arr.add("U"); + arr1.add(quadrat.getU()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Seite A\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } } - if(tf_Quadrat_U.getText().isEmpty()) { - tf_Quadrat_U.setText(String.valueOf((double) Math.round(quadrat.getU() * div) / div).replace(".", ",")); + if (!tf_Quadrat_U.getText().isEmpty()) { + try { + quadrat.setU(Double.parseDouble(tf_Quadrat_U.getText().replaceAll(",", "."))); + i++; + arr.add("diag"); + arr1.add(((Quadrat) quadrat).getD()); + } catch (NumberFormatException e1) { + JOptionPane.showMessageDialog(frmGeometrie, "Ung�ltiger Wert \"Umfang\" ", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + if (i == 1) { + if (!Datenbank.getDB(quadrat, arr, arr1)) { + quadrat1.calculate(); + } + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Bitte einen Wert angeben.", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + if (((Quadrat) quadrat).getSidea() != null && (((Quadrat) quadrat).getSidea() > 0) + && ((Quadrat) quadrat).getD() != null && ((Quadrat) quadrat).getD() > 0) { + Datenbank.save_DB(quadrat); + if (tf_Quadrat_sidea.getText().isEmpty()) { + tf_Quadrat_sidea + .setText(String.valueOf((double) Math.round(((Quadrat) quadrat).getSidea() * 100) / 100) + .replace(".", ",")); + } + if (tf_Quadrat_diag.getText().isEmpty()) { + tf_Quadrat_diag + .setText(String.valueOf((double) Math.round(((Quadrat) quadrat).getD() * 100) / 100) + .replace(".", ",")); + } + if (tf_Quadrat_A.getText().isEmpty()) { + tf_Quadrat_A.setText( + String.valueOf((double) Math.round(quadrat.getA() * 100) / 100).replace(".", ",")); + } + if (tf_Quadrat_U.getText().isEmpty()) { + tf_Quadrat_U.setText( + String.valueOf((double) Math.round(quadrat.getU() * 100) / 100).replace(".", ",")); + } + } else { + JOptionPane.showMessageDialog(frmGeometrie, "Quadrat ist nicht Konstruierbar!", "Error", + JOptionPane.ERROR_MESSAGE); } - } else { - JOptionPane.showMessageDialog(frmGeometrie, "Quadrat ist nicht Konstruierbar!", "Error", JOptionPane.ERROR_MESSAGE); - } } }); GridBagConstraints gbc_btnQuadrat_calc = new GridBagConstraints(); @@ -1638,14 +1704,14 @@ public void actionPerformed(ActionEvent e) { gbc_btnQuadrat_calc.gridx = 5; gbc_btnQuadrat_calc.gridy = 6; panel_Quadrat_1.add(btnQuadrat_calc, gbc_btnQuadrat_calc); - + JButton btnQuadrat_clear = new JButton("L\u00F6schen"); btnQuadrat_clear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - tf_Quadrat_A.setText(null); - tf_Quadrat_diag.setText(null); - tf_Quadrat_sidea.setText(null); - tf_Quadrat_U.setText(null); + tf_Quadrat_A.setText(null); + tf_Quadrat_diag.setText(null); + tf_Quadrat_sidea.setText(null); + tf_Quadrat_U.setText(null); } }); GridBagConstraints gbc_btnQuadrat_clear = new GridBagConstraints(); @@ -1656,17 +1722,17 @@ public void actionPerformed(ActionEvent e) { JPanel panel = new JPanel(); frmGeometrie.getContentPane().add(panel, "panel_showall"); - + tableModel = Datenbank.getall("Rechteck", tableModel); GridBagLayout gbl_panel = new GridBagLayout(); - gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0}; - gbl_panel.rowHeights = new int[]{0, 100, 0}; - gbl_panel.columnWeights = new double[]{1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE}; - gbl_panel.rowWeights = new double[]{0.0, 1.0, Double.MIN_VALUE}; + gbl_panel.columnWidths = new int[] { 0, 0, 0, 0, 0 }; + gbl_panel.rowHeights = new int[] { 0, 100, 0 }; + gbl_panel.columnWeights = new double[] { 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE }; + gbl_panel.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); database = new JTable(tableModel); - database.setShowGrid(true); - database.setShowVerticalLines(true); + database.setShowGrid(true); + database.setShowVerticalLines(true); ButtonGroup gruppe = new ButtonGroup(); JRadioButton rdbtnNewRadioButton = new JRadioButton("Rechteck"); rdbtnNewRadioButton.addActionListener(new ActionListener() { @@ -1686,7 +1752,7 @@ public void actionPerformed(ActionEvent e) { panel.add(rdbtnNewRadioButton, gbc_rdbtnNewRadioButton); rdbtnNewRadioButton.setSelected(true); gruppe.add(rdbtnNewRadioButton); - + JRadioButton rdbtnNewRadioButton_1 = new JRadioButton("Quadrat"); rdbtnNewRadioButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1703,7 +1769,7 @@ public void actionPerformed(ActionEvent e) { gbc_rdbtnNewRadioButton_1.gridy = 0; panel.add(rdbtnNewRadioButton_1, gbc_rdbtnNewRadioButton_1); gruppe.add(rdbtnNewRadioButton_1); - + JRadioButton rdbtnNewRadioButton_2 = new JRadioButton("Kreis"); rdbtnNewRadioButton_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1720,7 +1786,7 @@ public void actionPerformed(ActionEvent e) { gbc_rdbtnNewRadioButton_2.gridy = 0; panel.add(rdbtnNewRadioButton_2, gbc_rdbtnNewRadioButton_2); gruppe.add(rdbtnNewRadioButton_2); - + JRadioButton rdbtnNewRadioButton_3 = new JRadioButton("Dreieck"); rdbtnNewRadioButton_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1736,7 +1802,7 @@ public void actionPerformed(ActionEvent e) { gbc_rdbtnNewRadioButton_3.gridx = 3; gbc_rdbtnNewRadioButton_3.gridy = 0; panel.add(rdbtnNewRadioButton_3, gbc_rdbtnNewRadioButton_3); - + gruppe.add(rdbtnNewRadioButton_3); JScrollPane scrollPane = new JScrollPane(database); @@ -1748,20 +1814,20 @@ public void actionPerformed(ActionEvent e) { gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 1; panel.add(scrollPane, gbc_scrollPane); - + JMenuBar menuBar = new JMenuBar(); frmGeometrie.setJMenuBar(menuBar); - + JMenu mnMenu = new JMenu("Menu"); menuBar.add(mnMenu); - + JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); - + JMenuItem mntmMainmenu = new JMenuItem("Hauptmen\u00FC"); mntmMainmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1769,21 +1835,21 @@ public void actionPerformed(ActionEvent e) { } }); mnMenu.add(mntmMainmenu); - + JMenuItem mntmNewMenuItem_4 = new JMenuItem("Alle Eintr\u00E4ge zeigen"); mntmNewMenuItem_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - System.out.println(gruppe); + //System.out.println(gruppe); myCL.show(frmGeometrie.getContentPane(), "panel_showall"); } }); mnMenu.add(mntmNewMenuItem_4); mntmExit.setHorizontalAlignment(SwingConstants.LEFT); mnMenu.add(mntmExit); - + JMenu mnNewMenu_2 = new JMenu("Formen"); menuBar.add(mnNewMenu_2); - + JMenuItem mntmNewMenuItem = new JMenuItem("Kreis"); mntmNewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1791,7 +1857,7 @@ public void actionPerformed(ActionEvent e) { } }); mnNewMenu_2.add(mntmNewMenuItem); - + JMenuItem mntmNewMenuItem_3 = new JMenuItem("Dreieck"); mntmNewMenuItem_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1799,7 +1865,7 @@ public void actionPerformed(ActionEvent e) { } }); mnNewMenu_2.add(mntmNewMenuItem_3); - + JMenuItem mntmNewMenuItem_1 = new JMenuItem("Quadrat"); mntmNewMenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1807,7 +1873,7 @@ public void actionPerformed(ActionEvent e) { } }); mnNewMenu_2.add(mntmNewMenuItem_1); - + JMenuItem mntmNewMenuItem_2 = new JMenuItem("Rechteck"); mntmNewMenuItem_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1816,11 +1882,12 @@ public void actionPerformed(ActionEvent e) { } }); mnNewMenu_2.add(mntmNewMenuItem_2); - + } - + /** * Resizes the Image. + * * @param originalImage * @param targetWidth * @param targetHeight @@ -1829,10 +1896,10 @@ public void actionPerformed(ActionEvent e) { */ BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) throws IOException { - BufferedImage resizedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_ARGB); - Graphics2D graphics2D = resizedImage.createGraphics(); - graphics2D.drawImage(originalImage, 0, 0, targetWidth, targetHeight, null); - graphics2D.dispose(); - return resizedImage; + BufferedImage resizedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_ARGB); + Graphics2D graphics2D = resizedImage.createGraphics(); + graphics2D.drawImage(originalImage, 0, 0, targetWidth, targetHeight, null); + graphics2D.dispose(); + return resizedImage; } } \ No newline at end of file diff --git a/src/Quadrat.java b/src/Quadrat.java index f5e6b8b..224357d 100644 --- a/src/Quadrat.java +++ b/src/Quadrat.java @@ -1,71 +1,76 @@ - public class Quadrat extends Figur { // Variables -protected Double sidea; -protected Double d; + protected Double sidea; + protected Double d; + // Getter & Setter -public Double getSidea() { - return sidea; -} -public void setSidea(Double a) { - this.sidea = a; -} -public Double getD() { - return d; -} -public void setD(Double d) { - this.d = d; -} + public Double getSidea() { + return sidea; + } + + public void setSidea(Double a) { + this.sidea = a; + } + + public Double getD() { + return d; + } + + public void setD(Double d) { + this.d = d; + } // Constructor -public Quadrat() { - super(); -} -public Quadrat(Double a, Double a2, Double u, Double diag) { - super(); - this.sidea = a; - A = a2; - U = u; - this.d = diag; -} + public Quadrat() { + super(); + } + + public Quadrat(Double a, Double a2, Double u, Double diag) { + super(); + this.sidea = a; + A = a2; + U = u; + this.d = diag; + } + // Functions -/* - * U = Umfang - * A = Fläche - * sidea = Seite a - * d = Diagonale - */ -/** - * This is the Main Calculation for the Quadrat - * The Calculation checks for every Possible Combination of the Inputs. - */ -public void calculate() { -if (sidea != null) { - A = flaeche(); - U=umfang(); - d=diag(); -} else if (U != null) { - sidea = U/4; - A = flaeche(); - d = diag(); -} else if (A != null) { - sidea = Math.sqrt(A); - U=umfang(); - d = diag(); -} else if (d != null) { - sidea = d / Math.sqrt(2); - A = flaeche(); - U=umfang(); -}} -private double flaeche() { - return sidea*sidea; -} + /* + * U = Umfang A = Fl�che sidea = Seite a d = Diagonale + */ + /** + * This is the Main Calculation for the Quadrat The Calculation checks for every + * Possible Combination of the Inputs. + */ + public void calculate() { + if (sidea != null) { + A = flaeche(); + U = umfang(); + d = diag(); + } else if (U != null) { + sidea = U / 4; + A = flaeche(); + d = diag(); + } else if (A != null) { + sidea = Math.sqrt(A); + U = umfang(); + d = diag(); + } else if (d != null) { + sidea = d / Math.sqrt(2); + A = flaeche(); + U = umfang(); + } + } + + private double flaeche() { + return sidea * sidea; + } -private double umfang() { - return 4*sidea; -} + private double umfang() { + return 4 * sidea; + } -private double diag() { - return Math.sqrt(Math.pow(sidea, 2)+Math.pow(sidea, 2)); -}} \ No newline at end of file + private double diag() { + return Math.sqrt(Math.pow(sidea, 2) + Math.pow(sidea, 2)); + } +} \ No newline at end of file diff --git a/src/Rechteck.java b/src/Rechteck.java index 37e8d44..ee9ef30 100644 --- a/src/Rechteck.java +++ b/src/Rechteck.java @@ -3,359 +3,369 @@ public class Rechteck extends Quadrat { //Variables -private Double sideb; -private Double alpha; -private Double beta; -private Double gamma; -private Double delta; + private Double sideb; + private Double alpha; + private Double beta; + private Double gamma; + private Double delta; // Getter & Setter + public Double getSideb() { + return sideb; + } + + public void setSideb(Double sideb) { + this.sideb = sideb; + } + + public Double getAlpha() { + return alpha; + } + + public void setAlpha(Double alpha) { + this.alpha = alpha; + } + + public Double getBeta() { + return beta; + } + + public void setBeta(Double beta) { + this.beta = beta; + } + + public Double getGamma() { + return gamma; + } + + public void setGamma(Double gamma) { + this.gamma = gamma; + } + + public Double getDelta() { + return delta; + } + + public void setDelta(Double delta) { + this.delta = delta; + } -public Double getSideb() { - return sideb; -} -public void setSideb(Double sideb) { - this.sideb = sideb; -} -public Double getAlpha() { - return alpha; -} -public void setAlpha(Double alpha) { - this.alpha = alpha; -} -public Double getBeta() { - return beta; -} -public void setBeta(Double beta) { - this.beta = beta; -} -public Double getGamma() { - return gamma; -} -public void setGamma(Double gamma) { - this.gamma = gamma; -} -public Double getDelta() { - return delta; -} -public void setDelta(Double delta) { - this.delta = delta; -} //Constructor -public Rechteck() { - super(); -} -public Rechteck(Double sidea, Double sideb, Double a, Double d, Double alpha, Double beta, Double gamma, Double delta) { - super(); - this.sideb = sideb; - this.A = a; - this.alpha = alpha; - this.beta = beta; - this.gamma = gamma; - this.delta = delta; -} + public Rechteck() { + super(); + } + + public Rechteck(Double sidea, Double sideb, Double a, Double d, Double alpha, Double beta, Double gamma, + Double delta) { + super(); + this.sideb = sideb; + this.A = a; + this.alpha = alpha; + this.beta = beta; + this.gamma = gamma; + this.delta = delta; + } // Functions -/* - * U = Umfang - * A = Fläche - * sidea = Seite a - * sideb = Seite b - * d = Diagonale - * alpha = Winkel Alpha - * beta = Winkel Beta - * gamma = Winkel Gamma - * Delta = Winkel Delta - */ + /* + * U = Umfang A = Fl�che sidea = Seite a sideb = Seite b d = Diagonale alpha = + * Winkel Alpha beta = Winkel Beta gamma = Winkel Gamma Delta = Winkel Delta + */ -/** - * This is the Main Calculation for the Rechteck - * The Calculation checks for every Possible Combination of the Inputs. - * @param test - */ -public void calculate() { - if (sidea != null) { - if (sideb != null) { - U(); - A(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - alpha = Math.toDegrees(Math.atan(sideb/sidea)); - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180 - gamma; + /** + * This is the Main Calculation for the Rechteck The Calculation checks for + * every Possible Combination of the Inputs. + * + * @param test + */ + public void calculate() { + if (sidea != null) { + if (sideb != null) { + U(); + A(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + alpha = Math.toDegrees(Math.atan(sideb / sidea)); + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + } else if (A != null) { + sideb = A / sidea; + U(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + alpha = Math.toDegrees(Math.atan(sideb / sidea)); + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + } else if (U != null && U > ((double) sidea * 2)) { + sideb = U / 2 - sidea; + A(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + alpha = Math.toDegrees(Math.atan(sideb / sidea)); + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + } else if (d != null) { + sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); + U(); + A(); + alpha = Math.toDegrees(Math.atan(sideb / sidea)); + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + } else if (alpha != null && alpha < 90) { + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + d = sidea / Math.cos(Math.toRadians(alpha)); + sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); + U(); + A(); + } else if (beta != null && beta < 90) { + alpha = 90 - beta; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + d = sidea / Math.cos(Math.toRadians(alpha)); + sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); + U(); + A(); + } else if (gamma != null && gamma < 180) { + alpha = 90 - gamma / 2; + beta = 90 - alpha; + delta = 180 - gamma; + d = sidea / Math.cos(Math.toRadians(alpha)); + sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); + U(); + A(); + } else if (delta != null && delta < 180) { + gamma = 180 - delta; + alpha = 90 - gamma / 2; + beta = 90 - alpha; + d = sidea / Math.cos(Math.toRadians(alpha)); + sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); + U(); + A(); + } + } else if (sideb != null) { + if (A != null) { + sidea = A / sideb; + U(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + alpha = Math.toDegrees(Math.atan(sideb / sidea)); + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + } else if (U != null && U > ((double) sideb * 2)) { + sidea = U / 2 - sideb; + A(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + alpha = Math.toDegrees(Math.atan(sideb / sidea)); + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + } else if (d != null) { + sidea = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); + U(); + A(); + alpha = Math.toDegrees(Math.atan(sideb / sidea)); + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + } else if (alpha != null && alpha < 90) { + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + d = sideb / Math.sin(Math.toRadians(alpha)); + sidea = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); + U(); + A(); + } else if (beta != null && beta < 90) { + alpha = 90 - beta; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + d = sideb / Math.sin(Math.toRadians(alpha)); + sidea = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); + U(); + A(); + } else if (gamma != null && gamma < 180) { + alpha = 90 - gamma / 2; + beta = 90 - alpha; + delta = 180 - gamma; + d = sideb / Math.sin(Math.toRadians(alpha)); + sidea = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); + U(); + A(); + } else if (delta != null && delta < 180) { + gamma = 180 - delta; + alpha = 90 - gamma / 2; + beta = 90 - alpha; + d = sideb / Math.sin(Math.toRadians(alpha)); + sidea = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); + U(); + A(); + } } else if (A != null) { - sideb = A/sidea; - U(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - alpha = Math.toDegrees(Math.atan(sideb/sidea)); - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180 - gamma; - } else if (U != null && U>((double) sidea*2)) { - sideb = U/2 -sidea; - A(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - alpha = Math.toDegrees(Math.atan(sideb/sidea)); - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180 - gamma; - } else if (d != null) { - sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); - U(); - A(); - alpha = Math.toDegrees(Math.atan(sideb/sidea)); - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180 - gamma; - } else if (alpha != null && alpha < 90) { - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180 - gamma; - d = sidea/Math.cos(Math.toRadians(alpha)); - sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); - U(); - A(); - } else if (beta != null && beta < 90) { - alpha = 90 - beta; - gamma = 180 - 2*alpha; - delta = 180 - gamma; - d = sidea/Math.cos(Math.toRadians(alpha)); - sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); - U(); - A(); - } else if (gamma != null && gamma < 180) { - alpha = 90 - gamma/2; - beta = 90 - alpha; - delta = 180 - gamma; - d = sidea/Math.cos(Math.toRadians(alpha)); - sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); - U(); - A(); - } else if (delta != null && delta < 180) { - gamma = 180 - delta; - alpha = 90 - gamma/2; - beta = 90 - alpha; - d = sidea/Math.cos(Math.toRadians(alpha)); - sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); - U(); - A(); - } - } else if (sideb != null) { - if (A != null) { - sidea = A/sideb; - U(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - alpha = Math.toDegrees(Math.atan(sideb/sidea)); - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180 - gamma; - } else if (U != null && U>((double) sideb*2)) { - sidea = U/2-sideb; - A(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - alpha = Math.toDegrees(Math.atan(sideb/sidea)); - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180 - gamma; - } else if (d != null) { - sidea = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); - U(); - A(); - alpha = Math.toDegrees(Math.atan(sideb/sidea)); - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180 - gamma; - } else if (alpha != null && alpha < 90) { - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180 - gamma; - d = sideb/Math.sin(Math.toRadians(alpha)); - sidea = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); - U(); - A(); - } else if (beta != null && beta < 90) { - alpha = 90 - beta; - gamma = 180 - 2*alpha; - delta = 180 - gamma; - d = sideb/Math.sin(Math.toRadians(alpha)); - sidea = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); - U(); - A(); - } else if (gamma != null && gamma < 180) { - alpha = 90 - gamma/2; - beta = 90 - alpha; - delta = 180 - gamma; - d = sideb/Math.sin(Math.toRadians(alpha)); - sidea = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); - U(); - A(); - } else if (delta != null && delta < 180) { - gamma = 180 - delta; - alpha = 90 - gamma/2; - beta = 90 - alpha; - d = sideb/Math.sin(Math.toRadians(alpha)); - sidea = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); - U(); - A(); - } - } else if (A != null) { - if (U != null) { - sidea = (U - Math.sqrt(Math.pow(U, 2) - 16*A)) /4; - sideb = (U + Math.sqrt(Math.pow(U, 2) - 16*A)) /4; - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - alpha = Math.toDegrees(Math.atan(sideb/sidea)); - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180 - gamma; + if (U != null) { + sidea = (U - Math.sqrt(Math.pow(U, 2) - 16 * A)) / 4; + sideb = (U + Math.sqrt(Math.pow(U, 2) - 16 * A)) / 4; + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + alpha = Math.toDegrees(Math.atan(sideb / sidea)); + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + } else if (d != null) { + sidea = Math.sqrt(2 * (Math.pow(d, 2) - Math.sqrt(Math.pow(d, 4) - 4 * Math.pow(A, 2)))) / 2; + sideb = Math.sqrt(2 * (Math.pow(d, 2) + Math.sqrt(Math.pow(d, 4) - 4 * Math.pow(A, 2)))) / 2; + U(); + alpha = Math.toDegrees(Math.atan(sideb / sidea)); + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + } else if (alpha != null && alpha < 90) { + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + sideb = Math.sqrt(A * Math.tan(Math.toRadians(alpha))); + sidea = A / sideb; + U(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + } else if (beta != null && beta < 90) { + alpha = 90 - beta; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + sideb = Math.sqrt(A * Math.tan(Math.toRadians(alpha))); + sidea = A / sideb; + U(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + } else if (gamma != null && gamma < 180) { + alpha = 90 - gamma / 2; + beta = 90 - alpha; + delta = 180 - gamma; + sideb = Math.sqrt(A * Math.tan(Math.toRadians(alpha))); + sidea = A / sideb; + U(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + + } else if (delta != null && delta < 180) { + gamma = 180 - delta; + alpha = 90 - gamma / 2; + beta = 90 - alpha; + sideb = Math.sqrt(A * Math.tan(Math.toRadians(alpha))); + sidea = A / sideb; + U(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + } + } else if (U != null) { + if (alpha != null && alpha < 90) { + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + sidea = U / (2 * Math.tan(Math.toRadians(alpha)) + 1); + sideb = U / 2 - sidea; + A(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + } else if (beta != null && beta < 90) { + alpha = 90 - beta; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + sidea = U / (2 * Math.tan(Math.toRadians(alpha)) + 1); + sideb = U / 2 - sidea; + A(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + } else if (gamma != null && gamma < 180) { + alpha = 90 - gamma / 2; + beta = 90 - alpha; + delta = 180 - gamma; + sidea = U / (2 * Math.tan(Math.toRadians(alpha)) + 1); + sideb = U / 2 - sidea; + A(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + } else if (delta != null && delta < 180) { + gamma = 180 - delta; + alpha = 90 - gamma / 2; + beta = 90 - alpha; + sidea = U / (2 * Math.tan(Math.toRadians(alpha)) + 1); + sideb = U / 2 - sidea; + A(); + d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + } else if (d != null) { + if ((U > (d * 2)) && (d > (U / ((double) 1000 / 354)))) { + sidea = (U - Math.sqrt((8 * Math.pow(d, 2)) - Math.pow(U, 2))) / 4; + sideb = (U + Math.sqrt((8 * Math.pow(d, 2)) - Math.pow(U, 2))) / 4; + A(); + alpha = Math.toDegrees(Math.atan(sideb / sidea)); + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + + } + } } else if (d != null) { - sidea = Math.sqrt(2*(Math.pow(d, 2)-Math.sqrt(Math.pow(d, 4)-4*Math.pow(A, 2))))/2; - sideb = Math.sqrt(2*(Math.pow(d, 2)+Math.sqrt(Math.pow(d, 4)-4*Math.pow(A, 2))))/2; - U(); - alpha = Math.toDegrees(Math.atan(sideb/sidea)); - beta = 90-alpha; - gamma = 180 - 2*alpha; - delta=180-gamma; - } else if (alpha != null && alpha < 90) { - beta = 90-alpha; - gamma = 180 - 2*alpha; - delta=180-gamma; - sideb = Math.sqrt(A*Math.tan(Math.toRadians(alpha))); - sidea = A/sideb; - U(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - } else if (beta != null && beta < 90) { - alpha = 90-beta; - gamma = 180 - 2*alpha; - delta=180-gamma; - sideb = Math.sqrt(A*Math.tan(Math.toRadians(alpha))); - sidea = A/sideb; - U(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - } else if (gamma != null && gamma < 180) { - alpha = 90-gamma/2; - beta = 90 - alpha; - delta=180-gamma; - sideb = Math.sqrt(A*Math.tan(Math.toRadians(alpha))); - sidea = A/sideb; - U(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - - } else if (delta != null && delta < 180) { - gamma = 180 - delta; - alpha=90-gamma/2; - beta = 90-alpha; - sideb = Math.sqrt(A*Math.tan(Math.toRadians(alpha))); - sidea = A/sideb; - U(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); + if (alpha != null && alpha < 90) { + beta = 90 - alpha; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + sidea = d * Math.cos(Math.toRadians(alpha)); + sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); + U(); + A(); + } else if (beta != null && beta < 90) { + alpha = 90 - beta; + gamma = 180 - 2 * alpha; + delta = 180 - gamma; + sidea = d * Math.cos(Math.toRadians(alpha)); + sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); + U(); + A(); + } else if (gamma != null && gamma < 180) { + alpha = 90 - gamma / 2; + beta = 90 - alpha; + delta = 180 - gamma; + sidea = d * Math.cos(Math.toRadians(alpha)); + sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); + U(); + A(); + } else if (delta != null && delta < 180) { + gamma = 180 - delta; + alpha = 90 - gamma / 2; + beta = 90 - alpha; + sidea = d * Math.cos(Math.toRadians(alpha)); + sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); + U(); + A(); + } } - } else if (U != null) { - if (alpha != null && alpha < 90) { - beta = 90-alpha; - gamma = 180 - 2*alpha; - delta=180-gamma; - sidea = U/(2*Math.tan(Math.toRadians(alpha)) +1); - sideb = U/2 - sidea; - A(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - } else if (beta != null && beta < 90) { - alpha = 90-beta; - gamma = 180 - 2*alpha; - delta=180-gamma; - sidea = U/(2*Math.tan(Math.toRadians(alpha)) +1); - sideb = U/2 - sidea; - A(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - } else if (gamma != null && gamma < 180) { - alpha = 90-gamma/2; - beta = 90 - alpha; - delta=180-gamma; - sidea = U/(2*Math.tan(Math.toRadians(alpha)) +1); - sideb = U/2 - sidea; - A(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - } else if (delta != null && delta < 180) { - gamma = 180 - delta; - alpha=90-gamma/2; - beta = 90-alpha; - sidea = U/(2*Math.tan(Math.toRadians(alpha)) +1); - sideb = U/2 - sidea; - A(); - d = Math.sqrt(Math.pow(sidea, 2) + Math.pow(sideb, 2)); - } else if (d != null) { - if ((U>(d*2)) && (d>(U/((double) 1000/354)))) { - sidea = (U - Math.sqrt((8*Math.pow(d, 2))-Math.pow(U, 2)))/4; - sideb = (U + Math.sqrt((8*Math.pow(d, 2))-Math.pow(U, 2)))/4; - A(); - alpha = Math.toDegrees(Math.atan(sideb/sidea)); - beta = 90 - alpha; - gamma = 180 - 2*alpha; - delta = 180-gamma; - + if (sidea != null && sideb != null && A != null && U != null && d != null && alpha != null && beta != null + && gamma != null && delta != null) { + if (sidea > 0 && sideb > 0 && A > 0 && U > 0 && d > 0 && alpha > 0 && beta > 0 && gamma > 0 && delta > 0) { + // vartotest(test); + } else { + reset(); } + } else { + reset(); } - } else if (d != null) { - if (alpha != null && alpha < 90) { - beta = 90-alpha; - gamma = 180 - 2*alpha; - delta=180-gamma; - sidea = d*Math.cos(Math.toRadians(alpha)); - sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sidea, 2)); - U(); - A(); - } else if (beta != null && beta < 90) { - alpha = 90-beta; - gamma = 180 - 2*alpha; - delta=180-gamma; - sidea = d*Math.cos(Math.toRadians(alpha)); - sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); - U(); - A(); - } else if (gamma != null && gamma < 180) { - alpha = 90-gamma/2; - beta = 90 - alpha; - delta=180-gamma; - sidea = d*Math.cos(Math.toRadians(alpha)); - sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); - U(); - A(); - } else if (delta != null && delta < 180) { - gamma = 180 - delta; - alpha=90-gamma/2; - beta = 90-alpha; - sidea = d*Math.cos(Math.toRadians(alpha)); - sideb = Math.sqrt(Math.pow(d, 2) - Math.pow(sideb, 2)); - U(); - A(); - } } - if (sidea!=null && sideb!=null && A!=null && U!=null && d!=null && alpha!=null && beta!=null && gamma!=null && delta!=null) { - if (sidea>0 && sideb>0 && A>0 && U>0 && d>0 && alpha>0 && beta>0 && gamma>0 && delta>0) { - //vartotest(test); - } else { - reset(); } - } else { - reset(); + + /** + * Resets all parameters if the Rechteck is not valid. + */ + private void reset() { + sidea = null; + sideb = null; + A = null; + U = null; + d = null; + alpha = null; + beta = null; + gamma = null; + delta = null; + } + + private void U() { + U = 2 * (sidea + sideb); + } + + private void A() { + A = sidea * sideb; } -} -/** - * Resets all parameters if the Rechteck is not valid. - */ -private void reset() { - sidea = null; - sideb = null; - A = null; - U=null; - d=null; - alpha=null; - beta=null; - gamma=null; - delta=null; -} -private void U() { - U = 2*(sidea + sideb); -} -private void A() { - A = sidea * sideb; -} }