-
Notifications
You must be signed in to change notification settings - Fork 187
Use monitor-aware coordinates in multi-zoom coordinate system #1711
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
Merged
HeikoKlare
merged 1 commit into
eclipse-platform:master
from
amartya4256:add_zoom_context_to_pt_rect
Jan 20, 2025
+335
−100
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
71 changes: 71 additions & 0 deletions
71
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/MonitorAwarePoint.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2025 Yatta Solutions and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * Yatta Solutions - initial API and implementation | ||
| *******************************************************************************/ | ||
| package org.eclipse.swt.graphics; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| import org.eclipse.swt.widgets.*; | ||
|
|
||
| /** | ||
| * Instances of this class represent {@link org.eclipse.swt.graphics.Point} | ||
| * objects along with the context of the monitor in relation to which they are | ||
| * placed on the display. The monitor awareness makes it easy to scale and | ||
| * translate the points between pixels and points. | ||
| * | ||
| * @since 3.129 | ||
| * @noreference This class is not intended to be referenced by clients | ||
| */ | ||
| public final class MonitorAwarePoint extends Point { | ||
|
|
||
| private static final long serialVersionUID = 6077427420686999194L; | ||
|
|
||
| private final Monitor monitor; | ||
|
|
||
| /** | ||
| * Constructs a new MonitorAwarePoint | ||
| * | ||
| * @param x the x coordinate of the point | ||
| * @param y the y coordinate of the point | ||
| * @param monitor the monitor with whose context the point is created | ||
| */ | ||
| public MonitorAwarePoint(int x, int y, Monitor monitor) { | ||
| super(x, y); | ||
| this.monitor = monitor; | ||
| } | ||
|
|
||
| /** | ||
| * {@return the monitor with whose context the instance is created} | ||
| */ | ||
| public Monitor getMonitor() { | ||
| return monitor; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object object) { | ||
| if (this == object) { | ||
| return true; | ||
| } | ||
| if (!super.equals(object)) { | ||
| return false; | ||
| } | ||
| MonitorAwarePoint other = (MonitorAwarePoint) object; | ||
| return Objects.equals(this.monitor, other.monitor); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(super.hashCode(), monitor); | ||
| } | ||
|
|
||
| } |
73 changes: 73 additions & 0 deletions
73
...es/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/MonitorAwareRectangle.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2025 Yatta Solutions and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * Yatta Solutions - initial API and implementation | ||
| *******************************************************************************/ | ||
| package org.eclipse.swt.graphics; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| import org.eclipse.swt.widgets.*; | ||
|
|
||
| /** | ||
| * Instances of this class represent {@link org.eclipse.swt.graphics.Rectangle} | ||
| * objects along with the context of the monitor in relation to which they are | ||
| * placed on the display. The monitor awareness makes it easy to scale and | ||
| * translate the rectangles between pixels and points. | ||
| * | ||
| * @since 3.129 | ||
| * @noreference This class is not intended to be referenced by clients | ||
| */ | ||
| public final class MonitorAwareRectangle extends Rectangle { | ||
|
|
||
| private static final long serialVersionUID = 5041911840525116925L; | ||
|
|
||
| private final Monitor monitor; | ||
|
|
||
| /** | ||
| * Constructs a new MonitorAwareRectangle | ||
| * | ||
| * @param x the x coordinate of the top left corner of the rectangle | ||
| * @param y the y coordinate of the top left corner of the rectangle | ||
| * @param width the width of the rectangle | ||
| * @param height the height of the rectangle | ||
| * @param monitor the monitor with whose context the rectangle is created | ||
| */ | ||
| public MonitorAwareRectangle(int x, int y, int width, int height, Monitor monitor) { | ||
| super(x, y, width, height); | ||
| this.monitor = monitor; | ||
| } | ||
|
|
||
| /** | ||
| * {@return the monitor with whose context the instance is created} | ||
| */ | ||
| public Monitor getMonitor() { | ||
| return monitor; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object object) { | ||
| if (this == object) { | ||
| return true; | ||
| } | ||
| if (!super.equals(object)) { | ||
| return false; | ||
| } | ||
| MonitorAwareRectangle other = (MonitorAwareRectangle) object; | ||
| return Objects.equals(this.monitor, other.monitor); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(super.hashCode(), monitor); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.