Last active
September 5, 2024 19:02
-
-
Save trikitrok/7bd02fee265c3f5a96aec9381c50d4c9 to your computer and use it in GitHub Desktop.
Step 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1 | |
class GDIBrush | |
{ | |
private int colorId; | |
// A long method | |
public void draw(List<Point> renderingRoots, | |
ColorMatrix colors, | |
List<Point> selection) | |
{ | |
// !!! -> we wrote this line and used the IDE to generate the new class | |
new Renderer(this, renderingRoots, colors, selection); | |
// some more code in the method | |
for (Point point : renderingRoots) | |
{ | |
// a lot more code in the loop | |
drawPoint(point.x(), point.y(), colors.getColor(colorId)); | |
} | |
// a lot more code in the method | |
} | |
private void drawPoint(int x, int y, Color color) | |
{ | |
// some code to draw a point... | |
} | |
} | |
// !!! -> new class | |
class Renderer { | |
private final GDIBrush brush; | |
private final List<Point> renderingRoots; | |
private final ColorMatrix colors; | |
private final List<Point> selection; | |
public Renderer(GDIBrush brush, List<Point> renderingRoots, ColorMatrix colors, List<Point> selection) { | |
this.brush = brush; | |
this.renderingRoots = renderingRoots; | |
this.colors = colors; | |
this.selection = selection; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment