Skip to content

Commit

Permalink
Merge pull request #4557 from kwvanderlinde/bugfix/3691-note-rendering
Browse files Browse the repository at this point in the history
Fix note rendering when labels are present.
  • Loading branch information
cwisniew authored Dec 15, 2023
2 parents 0adc8b7 + 57b7dac commit cf94671
Showing 1 changed file with 7 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -819,9 +819,12 @@ public void paintComponent(Graphics g) {
timer.stop("paintComponent:createView");

renderZone(bufferG2d, pl);
int noteVPos = 20;
if (MapTool.getFrame().areFullScreenToolsShown()) noteVPos += 40;

int noteVPos = 20;
bufferG2d.setFont(AppStyle.labelFont);
if (MapTool.getFrame().areFullScreenToolsShown()) {
noteVPos += 40;
}
if (!AppPreferences.getMapVisibilityWarning() && (!zone.isVisible() && pl.isGMView())) {
GraphicsUtil.drawBoxedString(
bufferG2d, I18N.getText("zone.map_not_visible"), getSize().width / 2, noteVPos);
Expand Down Expand Up @@ -921,8 +924,7 @@ public void renderZone(Graphics2D g2d, PlayerView view) {
final var timer = CodeTimer.get();

timer.start("setup");
// store previous rendering settings
RenderingHints oldRenderingHints = g2d.getRenderingHints();
g2d = (Graphics2D) g2d.create();

// Clear internal state
tokenLocationMap.clear();
Expand All @@ -936,14 +938,12 @@ public void renderZone(Graphics2D g2d, PlayerView view) {
Rectangle viewRect = new Rectangle(getSize().width, getSize().height);

g2d.setFont(AppStyle.labelFont);
Object oldAA = SwingUtil.useAntiAliasing(g2d);
SwingUtil.useAntiAliasing(g2d);

Area viewArea = new Area(viewRect);
// much of the raster code assumes the user clip is set
boolean resetClip = false;
if (g2d.getClipBounds() == null) {
g2d.setClip(0, 0, viewRect.width, viewRect.height);
resetClip = true;
}
// Are we still waiting to show the zone ?
if (isLoading()) {
Expand Down Expand Up @@ -1223,22 +1223,6 @@ public void renderZone(Graphics2D g2d, PlayerView view) {
timer.stop("lightSourceIconOverlay.paintOverlay");

debugRenderer.renderShapes(g2d, Arrays.asList(shape, shape2));

// g2d.setColor(Color.red);
// for (AreaMeta meta : getTopologyAreaData().getAreaList()) {
// Area area = new
// Area(meta.getArea().getBounds()).createTransformedArea(AffineTransform.getScaleInstance(getScale(),
// getScale()));
// area =
// area.createTransformedArea(AffineTransform.getTranslateInstance(zoneScale.getOffsetX(),
// zoneScale.getOffsetY()));
// g2d.draw(area);
// }
g2d.setRenderingHints(oldRenderingHints);

if (resetClip) {
g2d.setClip(null);
}
}

private void delayRendering(ItemRenderer renderer) {
Expand Down

0 comments on commit cf94671

Please sign in to comment.