Browse Source

Merge origin/master

Conflicts:
	src/wuerfelthreads/Start.java
	src/wuerfelthreads/view/WuerfelView.form
	src/wuerfelthreads/view/WuerfelView.java
master
BakeOrDie 4 years ago
parent
commit
0776dde7d5
3 changed files with 103 additions and 6 deletions
  1. 23
    6
      src/grafik/Gerade.java
  2. 26
    0
      src/grafik/logger/MyFormatter.java
  3. 54
    0
      src/grafik/logger/OhmLogger.java

+ 23
- 6
src/grafik/Gerade.java View File



package grafik; package grafik;


import grafik.logger.OhmLogger;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D; import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D; import java.awt.geom.Line2D;
import java.util.logging.Logger; import java.util.logging.Logger;
private Thread thd; private Thread thd;
private long sleepTime; private long sleepTime;
private static final float DICKE = 8f; private static final float DICKE = 8f;
private static Logger lg = Logger.getLogger("grafik");
private static Logger lg = OhmLogger.getLogger();
private float x1, x2, y1, y2;
public Gerade(long sleepTime) public Gerade(long sleepTime)
{ {
radius = 100; radius = 100;
pinsel = new BasicStroke(DICKE); pinsel = new BasicStroke(DICKE);
thd = null; thd = null;

start();
} }
public void start() public void start()
{ {
if (thd == null) if (thd == null)
{ {
lg.info("start");
thd = new Thread(this); thd = new Thread(this);
thd.start(); thd.start();
} }
} }
int breite = this.getWidth() - 1; int breite = this.getWidth() - 1;
int hoehe = this.getHeight() - 1; int hoehe = this.getHeight() - 1;
float x1 = breite/2f;
float y1 = hoehe/2f;
float x2 = (float) Math.sin(angle);
float y2 = 2;
x1 = breite/2f;
y1 = hoehe/2f;
/** Rotate with Angle, sin and cos */
// x2 = (float) (radius * Math.cos((2 * Math.PI * angle) / 360) + x1);
// y2 = (float) (radius * Math.sin((2 * Math.PI * angle) / 360) + y1);
line.setLine(x1, y1, x2, y2); line.setLine(x1, y1, x2, y2);
/** Rotate with transforms */

g2.translate(x1, y1);
g2.rotate(Math.toRadians(angle));
g2.setStroke(pinsel); g2.setStroke(pinsel);
g2.setPaint(Color.RED); g2.setPaint(Color.RED);

+ 26
- 0
src/grafik/logger/MyFormatter.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package grafik.logger;

import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;

/**
*
* @author chris
*/
public class MyFormatter extends Formatter {
@Override
public String format(LogRecord lr) {
String date = String.format("%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp", new Date(lr.getMillis()));
String s = ("| ")+lr.getMillis()+(" | ")+date+(" | ")+lr.getLevel().toString()+(" | ")+lr.getSourceClassName()+(" | ")+lr.getMessage()+(" | ")+"\n";
return s;
}
}

+ 54
- 0
src/grafik/logger/OhmLogger.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package grafik.logger;


import grafik.logger.MyFormatter;
import java.io.File;
import java.io.IOException;
import java.util.logging.*;



/**
*
* @author chris, hd
*/
public class OhmLogger
{
public OhmLogger()
{
}
private static Logger lg = null;
public static Logger getLogger()
{
if (lg == null)
{
lg = Logger.getLogger("OhmLogger");
initLogger();
}
return lg;
}
private static void initLogger()
{
try{
String datei = System.getProperty("java.io.tmpdir") + File.separator + "log.txt";
FileHandler fh = new FileHandler(datei);
ConsoleHandler ch = new ConsoleHandler();
lg.addHandler(fh);
ch.setFormatter(new MyFormatter());
lg.setUseParentHandlers(false);
lg.addHandler(ch);
lg.setLevel(Level.ALL);
}
catch(IOException ioex)
{
System.err.println(ioex);
}
}
}

Loading…
Cancel
Save