Skip to content

Fixes to compile/run with modern Java #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Slightly Improved Version
=========================

Based on blog post:
http://www.muonhunter.com/blog/installing-freerouting-on-kicad

This build requires both
* javaws.jar
* jh.jar

Fixes for modern Java Rectangle -> Rectangle2D usage.

FreeRouting
===========

Expand Down
15 changes: 9 additions & 6 deletions boardgraphics/CoordinateTransform.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.awt.Dimension;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

/**
* Transformation function between the board and the screen coordinate systems.
Expand Down Expand Up @@ -60,7 +61,8 @@ public CoordinateTransform(IntBox p_design_box, Dimension p_panel_bounds )
display_y_offset = scale_factor * design_box_with_offset.ll.y ;
}

/** Copy constructor */
/** Copy constructor
* @param p_coordinate_transform */
public CoordinateTransform(CoordinateTransform p_coordinate_transform)
{
this.screen_bounds = new Dimension(p_coordinate_transform.screen_bounds);
Expand Down Expand Up @@ -175,17 +177,17 @@ public double board_to_screen_angle(double p_angle)
* If the internal rotation is not a multiple of Pi/2, a bounding rectangle of the
* rotated rectangular shape is returned.
*/
public java.awt.Rectangle board_to_screen(IntBox p_box)
public Rectangle2D board_to_screen(IntBox p_box)
{
Point2D corner_1 = board_to_screen(p_box.ll.to_float());
Point2D corner_2 = board_to_screen(p_box.ur.to_float());
double ll_x = Math.min(corner_1.getX(), corner_2.getX());
double ll_y = Math.min(corner_1.getY(), corner_2.getY());
double dx = Math.abs(corner_2.getX() - corner_1.getX());
double dy = Math.abs(corner_2.getY() - corner_1.getY());
java.awt.Rectangle result =
new java.awt. Rectangle((int) Math.floor(ll_x), (int) Math.floor(ll_y),
(int) Math.ceil(dx), (int) Math.ceil(dy));
Rectangle2D result =
new Rectangle2D.Double(Math.floor(ll_x), Math.floor(ll_y),
Math.ceil(dx), Math.ceil(dy));
return result;
}

Expand All @@ -194,7 +196,7 @@ public java.awt.Rectangle board_to_screen(IntBox p_box)
* If the internal rotation is not a multiple of Pi/2, a bounding box of the
* rotated rectangular shape is returned.
*/
public IntBox screen_to_board(java.awt.Rectangle p_rect)
public IntBox screen_to_board(Rectangle2D p_rect)
{
FloatPoint corner_1 = screen_to_board(new Point2D.Double(p_rect.getX(), p_rect.getY()));
FloatPoint corner_2 = screen_to_board(new Point2D.Double(p_rect.getX() + p_rect.getWidth(),
Expand Down Expand Up @@ -296,4 +298,5 @@ public int get_90_degree_rotation()
private double rotation = 0;

private FloatPoint rotation_pole;

}
21 changes: 10 additions & 11 deletions boardgraphics/GraphicsContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
Expand Down Expand Up @@ -127,7 +126,7 @@ public void draw(FloatPoint[] p_points, double p_half_width, Color p_color, Grap
return;
}
Graphics2D g2 = (Graphics2D)p_g;
Rectangle clip_shape = (Rectangle)p_g.getClip() ;
Rectangle2D clip_shape = (Rectangle2D)p_g.getClip() ;
// the class member update_box cannot be used here, because
// the dirty rectangle is internally enlarged by the system.
// Therefore we can not improve the performance by using an
Expand Down Expand Up @@ -270,7 +269,7 @@ public void fill_circle(Circle p_circle, Graphics p_g, Color p_color, double p_t
}
Point2D center = coordinate_transform.board_to_screen(p_circle.center.to_float());
double radius = coordinate_transform.board_to_screen(p_circle.radius);
if (!point_near_rectangle(center.getX(), center.getY(), (Rectangle)p_g.getClip(), radius))
if (!point_near_rectangle(center.getX(), center.getY(), (Rectangle2D)p_g.getClip(), radius))
{
return;
}
Expand Down Expand Up @@ -310,7 +309,7 @@ public void fill_ellipse_arr(Ellipse [] p_ellipse_arr, Graphics p_g, Color p_co
{
Point2D center = coordinate_transform.board_to_screen(curr_ellipse.center);
double bigger_radius = coordinate_transform.board_to_screen(curr_ellipse.bigger_radius);
if (!point_near_rectangle(center.getX(), center.getY(), (Rectangle)p_g.getClip(), bigger_radius))
if (!point_near_rectangle(center.getX(), center.getY(), (Rectangle2D)p_g.getClip(), bigger_radius))
{
continue;
}
Expand All @@ -334,21 +333,21 @@ public void fill_ellipse_arr(Ellipse [] p_ellipse_arr, Graphics p_g, Color p_co
/**
* Checks, if the distance of the point with coordinates p_x, p_y to p_rect ist at most p_dist.
*/
private boolean point_near_rectangle(double p_x, double p_y, Rectangle p_rect, double p_dist)
private boolean point_near_rectangle(double p_x, double p_y, Rectangle2D p_rect, double p_dist)
{
if (p_x < p_rect.x - p_dist)
if (p_x < p_rect.getX() - p_dist)
{
return false;
}
if (p_y < p_rect.y - p_dist)
if (p_y < p_rect.getY() - p_dist)
{
return false;
}
if (p_x > p_rect.x + p_rect.width + p_dist)
if (p_x > p_rect.getX() + p_rect.getWidth() + p_dist)
{
return false;
}
if (p_y > p_rect.y + p_rect.height + p_dist)
if (p_y > p_rect.getY() + p_rect.getHeight() + p_dist)
{
return false;
}
Expand Down Expand Up @@ -429,7 +428,7 @@ public void fill_area(Area p_area, Graphics p_g, Color p_color, double p_translu
System.out.println("GraphicsContext.fill_area: shape not bounded");
return;
}
Rectangle clip_shape = (Rectangle)p_g.getClip() ;
Rectangle2D clip_shape = (Rectangle2D)p_g.getClip() ;
IntBox clip_box = coordinate_transform.screen_to_board(clip_shape);
if (!border.bounding_box().intersects(clip_box))
{
Expand Down Expand Up @@ -665,7 +664,7 @@ public Point2D get_design_center()
/**
* Returns the bounding box of the design in screen coordinates.
*/
public java.awt.Rectangle get_design_bounds()
public Rectangle2D get_design_bounds()
{
return coordinate_transform.board_to_screen(coordinate_transform.design_box);
}
Expand Down
5 changes: 3 additions & 2 deletions gui/BoardFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import board.BoardObservers;

import designformats.specctra.DsnFile;
import java.awt.Rectangle;

/**
*
Expand Down Expand Up @@ -422,8 +423,8 @@ java.awt.Point absolute_panel_location()
public void zoom_all()
{
board_panel.board_handling.adjust_design_bounds();
java.awt.Rectangle display_rect = board_panel.get_viewport_bounds();
java.awt.Rectangle design_bounds = board_panel.board_handling.graphics_context.get_design_bounds();
Rectangle display_rect = board_panel.get_viewport_bounds().getBounds();
Rectangle design_bounds = board_panel.board_handling.graphics_context.get_design_bounds().getBounds();
double width_factor = display_rect.getWidth() /design_bounds.getWidth();
double height_factor = display_rect.getHeight() /design_bounds.getHeight();
double zoom_factor = Math.min(width_factor, height_factor);
Expand Down
13 changes: 7 additions & 6 deletions interactive/BoardHandling.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import board.TestLevel;

import designformats.specctra.DsnFile;
import java.awt.geom.Rectangle2D;

/**
*
Expand Down Expand Up @@ -673,15 +674,15 @@ public void repaint()
/**
* Repaints a rectangle of board panel on the screen.
*/
public void repaint(Rectangle p_rect)
public void repaint(Rectangle2D p_rect)
{
if (this.paint_immediately)
{
panel.paintImmediately(p_rect);
panel.paintImmediately(p_rect.getBounds());
}
else
{
panel.repaint(p_rect);
panel.repaint(p_rect.getBounds());
}
}

Expand Down Expand Up @@ -1661,13 +1662,13 @@ public void start_adding_hole(Point2D p_point)
* Gets a surrounding rectangle of the area, where an update of the
* graphics is needed caused by the previous interactive actions.
*/
Rectangle get_graphics_update_rectangle()
Rectangle2D get_graphics_update_rectangle()
{
Rectangle result;
Rectangle2D result;
IntBox update_box = board.get_graphics_update_box();
if (update_box == null || update_box.is_empty())
{
result = new Rectangle(0, 0, 0, 0);
result = new Rectangle2D.Double(0, 0, 0, 0);
}
else
{
Expand Down
Binary file added javaws.jar
Binary file not shown.
Binary file added jh.jar
Binary file not shown.