本文整理汇总了Java中java.awt.Dimension.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Dimension.equals方法的具体用法?Java Dimension.equals怎么用?Java Dimension.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Dimension
的用法示例。
在下文中一共展示了Dimension.equals方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCanonicalForm
import java.awt.Dimension; //导入方法依赖的package包/类
/**
* Get the canonical form of this request.
*
* @See http://iiif.io/api/image/2.1/#canonical-uri-syntax
*/
public String getCanonicalForm(Dimension nativeSize, ImageApiProfile profile) {
Dimension resolved = this.resolve(nativeSize, profile);
// "w," requests are already canonical
double nativeRatio = nativeSize.getWidth() / nativeSize.getHeight();
double resolvedRatio = resolved.getWidth() / resolved.getHeight();
if (resolved.equals(nativeSize)) {
return "full";
} else if (this.width != null && this.height == null) {
return this.toString();
} else if (Math.floor(resolvedRatio * nativeSize.getHeight()) == nativeSize.getWidth() ||
Math.ceil(resolvedRatio * nativeSize.getHeight()) == nativeSize.getWidth()) {
return String.format("%d,", resolved.width);
} else {
return String.format("%d,%d", resolved.width, resolved.height);
}
}
示例2: ensurePreferredSize
import java.awt.Dimension; //导入方法依赖的package包/类
private void ensurePreferredSize() {
if( null != lastBounds ) {
return; //we remember the last window position
} //we remember the last window position
Dimension sz = dialog.getSize();
Dimension pref = dialog.getPreferredSize();
if (pref.height == 0) {
pref.height = SIZE_PREFERRED_HEIGHT;
}
if (pref.width == 0) {
pref.width = SIZE_PREFERRED_WIDTH;
}
if (!sz.equals(pref)) {
dialog.setSize(pref.width, pref.height);
dialog.validate();
dialog.repaint();
}
}
示例3: propertyChange
import java.awt.Dimension; //导入方法依赖的package包/类
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (task != null && IOResizable.PROP_SIZE.equals(evt.getPropertyName())) {
IOResizable.Size newVal = (IOResizable.Size) evt.getNewValue();
if (newVal != null) {
Dimension newCells = newVal.cells;
Dimension newPixels = newVal.pixels;
if (newCells == null || newPixels == null) {
throw new NullPointerException();
}
if (newCells.equals(this.cells) && newPixels.equals(this.pixels)) {
return;
}
this.cells = new Dimension(newCells);
this.pixels = new Dimension(newPixels);
task.schedule(1000);
}
}
}
示例4: main
import java.awt.Dimension; //导入方法依赖的package包/类
public static void main(final String[] args) {
final Frame frame = new Frame();
final TextArea ta = new TextArea();
frame.add(ta);
frame.pack();
frame.setVisible(true);
sleep();
final Dimension before = frame.getSize();
frame.pack();
final Dimension after = frame.getSize();
if (!after.equals(before)) {
throw new RuntimeException(
"Expected size: " + before + ", actual size: " + after);
}
frame.dispose();
}
示例5: doTest
import java.awt.Dimension; //导入方法依赖的package包/类
boolean doTest() {
Dimension beforeMaximizeCalled = new Dimension(300,300);
frame = new Frame("Test Frame");
frame.setUndecorated(true);
frame.setFocusable(true);
frame.setSize(beforeMaximizeCalled);
frame.setVisible(true);
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setExtendedState(Frame.NORMAL);
Dimension afterMaximizedCalled= frame.getBounds().getSize();
frame.dispose();
if (beforeMaximizeCalled.equals(afterMaximizedCalled)) {
return true;
}
return false;
}
示例6: testHeadful
import java.awt.Dimension; //导入方法依赖的package包/类
private static void testHeadful() {
GraphicsEnvironment ge
= GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc
= ge.getDefaultScreenDevice().getDefaultConfiguration();
Dimension gcSize = gc.getBounds().getSize();
ColorModel gcCM = gc.getColorModel();
Dimension toolkitSize = Toolkit.getDefaultToolkit().getScreenSize();
ColorModel toolkitCM = Toolkit.getDefaultToolkit().getColorModel();
if (!gcSize.equals(toolkitSize)) {
System.err.println("Toolkit size = " + toolkitSize);
System.err.println("GraphicsConfiguration size = " + gcSize);
throw new RuntimeException("Incorrect size");
}
if (!gcCM.equals(toolkitCM)) {
System.err.println("Toolkit color model = " + toolkitCM);
System.err.println("GraphicsConfiguration color model = " + gcCM);
throw new RuntimeException("Incorrect color model");
}
}
示例7: show
import java.awt.Dimension; //导入方法依赖的package包/类
/**
* Create and display the popup at the given bounds.
*
* @param popupBounds location and size of the popup.
* @param displayAboveCaret whether the popup is displayed above the anchor
* bounds or below them (it does not be right above them).
*/
private void show(Rectangle popupBounds, boolean displayAboveCaret) {
// Hide the original popup if exists
if (popup != null) {
popup.hide();
popup = null;
}
// Explicitly set the preferred size
Dimension origPrefSize = getPreferredSize();
Dimension newPrefSize = popupBounds.getSize();
JComponent contComp = getContentComponent();
if (contComp == null){
return;
}
contComp.setPreferredSize(newPrefSize);
showRetainedPreferredSize = newPrefSize.equals(origPrefSize);
PopupFactory factory = PopupFactory.getSharedInstance();
// Lightweight completion popups don't work well on the Mac - trying
// to click on its scrollbars etc. will cause the window to be hidden,
// so force a heavyweight parent by passing in owner==null. (#96717)
JTextComponent owner = layout.getEditorComponent();
if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) {
owner = null;
}
// #76648: Autocomplete box is too close to text
if(displayAboveCaret && Utilities.isMac()) {
popupBounds.y -= 10;
}
popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y);
popup.show();
this.popupBounds = popupBounds;
this.displayAboveCaret = displayAboveCaret;
}
示例8: initBounds
import java.awt.Dimension; //导入方法依赖的package包/类
private void initBounds() {
Window w = findFocusedWindow();
if( null != w ) {
//#133235 - dialog windows should be centered on the main app window, not the whole screen
setLocationRelativeTo( w );
Rectangle screen = Utilities.getUsableScreenBounds( w.getGraphicsConfiguration() );
Rectangle bounds = getBounds();
int dx = bounds.x;
int dy = bounds.y;
// bottom
if (dy + bounds.height > screen.y + screen.height) {
dy = screen.y + screen.height - bounds.height;
}
// top
if (dy < screen.y) {
dy = screen.y;
}
// right
if (dx + bounds.width > screen.x + screen.width) {
dx = screen.x + screen.width - bounds.width;
}
// left
if (dx < screen.x) {
dx = screen.x;
}
setLocation( dx, dy );
} else {
//just center the dialog on the screen and let's hope it'll be
//the correct one in multi-monitor setup
Dimension size = getSize();
Rectangle centerBounds = Utilities.findCenterBounds(size);
if(size.equals(centerBounds.getSize())) {
setLocation(centerBounds.x, centerBounds.y);
} else {
setBounds(centerBounds);
}
}
}
示例9: show
import java.awt.Dimension; //导入方法依赖的package包/类
/**
* Create and display the popup at the given bounds.
*
* @param popupBounds location and size of the popup.
* @param displayAboveCaret whether the popup is displayed above the anchor
* bounds or below them (it does not be right above them).
*/
private void show(Rectangle popupBounds, boolean displayAboveCaret) {
// Hide the original popup if exists
if (popup != null) {
popup.hide();
popup = null;
}
// Explicitly set the preferred size
Dimension origPrefSize = getPreferredSize();
Dimension newPrefSize = popupBounds.getSize();
JComponent contComp = getContentComponent();
if (contComp == null){
return;
}
contComp.setPreferredSize(newPrefSize);
showRetainedPreferredSize = newPrefSize.equals(origPrefSize);
PopupFactory factory = PopupFactory.getSharedInstance();
// Lightweight completion popups don't work well on the Mac - trying
// to click on its scrollbars etc. will cause the window to be hidden,
// so force a heavyweight parent by passing in owner==null. (#96717)
JTextComponent owner = getEditorComponent();
if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) { //NOI18N
owner = null;
}
// #76648: Autocomplete box is too close to text
if(displayAboveCaret && Utilities.isMac()) {
popupBounds.y -= 10;
}
popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y);
popup.show();
this.popupBounds = popupBounds;
this.displayAboveCaret = displayAboveCaret;
}
示例10: updateComponentSize
import java.awt.Dimension; //导入方法依赖的package包/类
/**
* Update preferred size of this {@link JComponent} and updates the subprocess extension buttons
* as well.
*/
private void updateComponentSize() {
Dimension newSize = new Dimension((int) controller.getTotalWidth(), (int) controller.getTotalHeight());
updateExtensionButtons();
if (!newSize.equals(getPreferredSize())) {
setPreferredSize(newSize);
revalidate();
}
}
示例11: testSize
import java.awt.Dimension; //导入方法依赖的package包/类
private static void testSize(final Dimension actual, final Dimension exp) {
if (!exp.equals(actual)) {
System.err.println(" Wrong window size:" +
" Expected: " + exp + " Actual: " + actual);
passed = false;
}
}
示例12: selectPlatform
import java.awt.Dimension; //导入方法依赖的package包/类
private void selectPlatform (Node pNode) {
Component active = null;
for (Component c : cards.getComponents()) {
if (c.isVisible() &&
(c == jPanel1 || c == messageArea)) {
active = c;
break;
}
}
final Dimension lastSize = active == null ?
null :
active.getSize();
this.clientArea.removeAll();
this.messageArea.removeAll();
this.removeButton.setEnabled (false);
if (pNode == null) {
((CardLayout)cards.getLayout()).last(cards);
return;
}
JComponent target = messageArea;
JComponent owner = messageArea;
JavaPlatform platform = pNode.getLookup().lookup(JavaPlatform.class);
if (pNode != getExplorerManager().getRootContext()) {
if (platform != null) {
this.removeButton.setEnabled (canRemove(platform, pNode.getLookup().lookup(DataObject.class)));
if (!platform.getInstallFolders().isEmpty()) {
this.platformName.setText(pNode.getDisplayName());
for (FileObject installFolder : platform.getInstallFolders()) {
File file = FileUtil.toFile(installFolder);
if (file != null) {
this.platformHome.setText (file.getAbsolutePath());
}
}
target = clientArea;
owner = jPanel1;
}
}
Component component = null;
if (pNode.hasCustomizer()) {
component = pNode.getCustomizer();
}
if (component == null) {
final PropertySheet sp = new PropertySheet();
sp.setNodes(new Node[] {pNode});
component = sp;
}
addComponent(target, component);
}
if (lastSize != null) {
final Dimension newSize = owner.getPreferredSize();
final Dimension updatedSize = new Dimension(
Math.max(lastSize.width, newSize.width),
Math.max(lastSize.height, newSize.height));
if (!newSize.equals(updatedSize)) {
owner.setPreferredSize(updatedSize);
}
}
target.revalidate();
CardLayout cl = (CardLayout) cards.getLayout();
if (target == clientArea) {
cl.first (cards);
}
else {
cl.last (cards);
}
}
示例13: selectPlatform
import java.awt.Dimension; //导入方法依赖的package包/类
private void selectPlatform(Node pNode) {
Component active = null;
for (Component c : cards.getComponents()) {
if (c.isVisible()
&& (c == jPanel1 || c == messageArea)) {
active = c;
break;
}
}
final Dimension lastSize = active == null
? null
: active.getSize();
this.clientArea.removeAll();
this.messageArea.removeAll();
this.removeButton.setEnabled(false);
if (pNode == null) {
((CardLayout) cards.getLayout()).last(cards);
return;
}
JComponent target = messageArea;
JComponent owner = messageArea;
selectedPlatform = pNode.getLookup().lookup(AndroidSdk.class);
if (pNode != getExplorerManager().getRootContext()) {
if (selectedPlatform != null) {
mkDefault.setEnabled(!selectedPlatform.isDefaultSdk());
this.removeButton.setEnabled(!selectedPlatform.isDefaultSdk());
if (!selectedPlatform.getInstallFolders().isEmpty()) {
this.platformName.setText(pNode.getDisplayName());
for (FileObject installFolder : selectedPlatform.getInstallFolders()) {
File file = FileUtil.toFile(installFolder);
if (file != null) {
this.platformHome.setText(file.getAbsolutePath());
}
}
target = clientArea;
owner = jPanel1;
}
} else {
removeButton.setEnabled(false);
mkDefault.setEnabled(false);
}
Component component = null;
if (pNode.hasCustomizer()) {
component = pNode.getCustomizer();
}
if (component == null) {
final PropertySheet sp = new PropertySheet();
sp.setNodes(new Node[]{pNode});
component = sp;
}
addComponent(target, component);
}
if (lastSize != null) {
final Dimension newSize = owner.getPreferredSize();
final Dimension updatedSize = new Dimension(
Math.max(lastSize.width, newSize.width),
Math.max(lastSize.height, newSize.height));
if (!newSize.equals(updatedSize)) {
owner.setPreferredSize(updatedSize);
}
}
target.revalidate();
CardLayout cl = (CardLayout) cards.getLayout();
if (target == clientArea) {
cl.first(cards);
} else {
cl.last(cards);
}
}
示例14: paint
import java.awt.Dimension; //导入方法依赖的package包/类
/**
* Paint the array of numbers as a list
* of horizontal lines of varying lengths.
*/
@Override
public void paint(Graphics g) {
int a[] = arr;
int y = 0;
int deltaY = 0, deltaX = 0, evenY = 0;
Dimension currentSize = getSize();
int currentHeight = currentSize.height;
int currentWidth = currentSize.width;
// Check to see if the applet has been resized since it
// started running. If so, need the deltas to make sure
// the applet is centered in its containing panel.
// The evenX and evenY are because the high and low
// watermarks are calculated from the top, but the rest
// of the lines are calculated from the bottom, which
// can lead to a discrepancy if the window is not an
// even size.
if (!currentSize.equals(initialSize)) {
evenY = (currentHeight - initialSize.height) % 2;
deltaY = (currentHeight - initialSize.height) / 2;
deltaX = (currentWidth - initialSize.width) / 2;
if (deltaY < 0) {
deltaY = 0;
evenY = 0;
}
if (deltaX < 0) {
deltaX = 0;
}
}
// Erase old lines
g.setColor(getBackground());
y = currentHeight - deltaY - 1;
for (int i = a.length; --i >= 0; y -= 2) {
g.drawLine(deltaX + arr[i], y, currentWidth, y);
}
// Draw new lines
g.setColor(Color.black);
y = currentHeight - deltaY - 1;
for (int i = a.length; --i >= 0; y -= 2) {
g.drawLine(deltaX, y, deltaX + arr[i], y);
}
if (h1 >= 0) {
g.setColor(Color.red);
y = deltaY + evenY + h1 * 2 + 1;
g.drawLine(deltaX, y, deltaX + initialSize.width, y);
}
if (h2 >= 0) {
g.setColor(Color.blue);
y = deltaY + evenY + h2 * 2 + 1;
g.drawLine(deltaX, y, deltaX + initialSize.width, y);
}
}