use of java.awt.event.MouseEvent in project android by JetBrains.
the class NlPreviewImagePanelTest method mousePressed.
private void mousePressed() {
int x = 10;
int y = 10;
MouseEvent event = new MouseEvent(myPanel, MOUSE_PRESSED, System.currentTimeMillis(), BUTTON1_MASK | BUTTON1_DOWN_MASK, x, y, 1, false);
for (MouseListener listener : myPanel.getMouseListeners()) {
listener.mousePressed(event);
}
}
use of java.awt.event.MouseEvent in project android by JetBrains.
the class CpuMonitorView method populateUi.
@Override
protected void populateUi(JPanel container, Choreographer choreographer) {
container.setLayout(new TabularLayout("*", "*"));
Range viewRange = getMonitor().getTimeline().getViewRange();
Range dataRange = getMonitor().getTimeline().getDataRange();
final JLabel label = new JLabel(getMonitor().getName());
label.setBorder(MONITOR_LABEL_PADDING);
label.setVerticalAlignment(JLabel.TOP);
// Cpu usage is shown as percentages (e.g. 0 - 100) and no range animation is needed.
Range leftYRange = new Range(0, 100);
final JPanel axisPanel = new JBPanel(new BorderLayout());
axisPanel.setOpaque(false);
AxisComponent.Builder builder = new AxisComponent.Builder(leftYRange, CPU_USAGE_AXIS, AxisComponent.AxisOrientation.RIGHT).showAxisLine(false).showMax(true).showUnitAtMax(true).setMarkerLengths(MARKER_LENGTH, MARKER_LENGTH).clampToMajorTicks(true).setMargins(0, Y_AXIS_TOP_MARGIN);
final AxisComponent leftAxis = builder.build();
axisPanel.add(leftAxis, BorderLayout.WEST);
final JPanel lineChartPanel = new JBPanel(new BorderLayout());
lineChartPanel.setOpaque(false);
lineChartPanel.setBorder(BorderFactory.createEmptyBorder(Y_AXIS_TOP_MARGIN, 0, 0, 0));
final LineChart lineChart = new LineChart();
RangedContinuousSeries cpuSeries = new RangedContinuousSeries("CPU", viewRange, leftYRange, getMonitor().getThisProcessCpuUsage());
lineChart.addLine(cpuSeries, new LineConfig(ProfilerColors.CPU_USAGE).setFilled(true));
lineChartPanel.add(lineChart, BorderLayout.CENTER);
final LegendComponent legend = new LegendComponent(LegendComponent.Orientation.HORIZONTAL, LEGEND_UPDATE_FREQUENCY_MS);
legend.setLegendData(Collections.singletonList(lineChart.createLegendRenderData(cpuSeries, CPU_USAGE_AXIS, dataRange)));
final JPanel legendPanel = new JBPanel(new BorderLayout());
legendPanel.setOpaque(false);
legendPanel.add(label, BorderLayout.WEST);
legendPanel.add(legend, BorderLayout.EAST);
choreographer.register(lineChart);
choreographer.register(leftAxis);
choreographer.register(legend);
container.add(legendPanel, new TabularLayout.Constraint(0, 0));
container.add(leftAxis, new TabularLayout.Constraint(0, 0));
container.add(lineChartPanel, new TabularLayout.Constraint(0, 0));
container.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
getMonitor().expand();
}
});
}
use of java.awt.event.MouseEvent in project android by JetBrains.
the class NlOldPalettePanel method enableClickToLoadMissingDependency.
private void enableClickToLoadMissingDependency() {
myPaletteTree.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent event) {
Palette.BaseItem object = getItemForPath(myPaletteTree.getPathForLocation(event.getX(), event.getY()));
if (needsLibraryLoad(object)) {
Palette.Item item = (Palette.Item) object;
String coordinate = item.getGradleCoordinateId();
assert coordinate != null;
Module module = getModule();
assert module != null;
GradleDependencyManager manager = GradleDependencyManager.getInstance(myProject);
manager.ensureLibraryIsIncluded(module, toGradleCoordinates(Collections.singletonList(coordinate)), null);
}
}
});
GradleSyncState.subscribe(myProject, new GradleSyncListener.Adapter() {
@Override
public void syncSucceeded(@NotNull Project project) {
if (checkForNewMissingDependencies()) {
repaint();
}
}
}, this);
}
use of java.awt.event.MouseEvent in project android by JetBrains.
the class GradleEditorCellComponentImpl method onMouseMove.
@Nullable
@Override
public Rectangle onMouseMove(@NotNull MouseEvent event) {
if (myEditor) {
return null;
}
if (!myToolBarPanel.isVisible() && !myTimer.isRunning()) {
onMouseEntered(event);
return null;
}
int row = myTable.getRowByComponent(this);
if (row < 0) {
return null;
}
int topY = 0;
for (int i = 0; i < row; i++) {
topY += myTable.getRowHeight(i);
}
setBounds(0, 0, myTable.getWidth(), myTable.getRowHeight(row));
Point pointInCurrentControl = new Point(event.getX(), event.getY() - topY);
Component c = SwingUtilities.getDeepestComponentAt(this, pointInCurrentControl.x, pointInCurrentControl.y);
boolean dirty = false;
if (myLastComponentUnderMouse != null && myLastComponentUnderMouse != c) {
Point p = SwingUtilities.convertPoint(this, pointInCurrentControl, myLastComponentUnderMouse);
MouseEvent e = new MouseEvent(c, MouseEvent.MOUSE_EXITED, event.getWhen(), event.getModifiers(), p.x, p.y, event.getClickCount(), event.isPopupTrigger(), event.getButton());
myLastComponentUnderMouse.dispatchEvent(e);
dirty = true;
Cursor cursor = myLastComponentUnderMouse.getCursor();
if (cursor != null && cursor == myTable.getCursor()) {
myTable.setCursor(null);
}
}
if (c != myLastComponentUnderMouse) {
Point p = SwingUtilities.convertPoint(this, pointInCurrentControl, c);
MouseEvent e = new MouseEvent(c, MouseEvent.MOUSE_ENTERED, event.getWhen(), event.getModifiers(), p.x, p.y, event.getClickCount(), event.isPopupTrigger(), event.getButton());
c.dispatchEvent(e);
dirty = true;
myTable.setCursor(c.getCursor());
}
myLastComponentUnderMouse = c;
Point tableLocationOnScreen = myTable.getLocationOnScreen();
if (!dirty) {
return null;
}
if (myToolBarPanelBounds == null) {
// Repaint the whole row.
return new Rectangle(tableLocationOnScreen.x, tableLocationOnScreen.y + topY, myTable.getWidth(), myTable.getRowHeight(row));
} else {
return new Rectangle(tableLocationOnScreen.x + myToolBarPanelBounds.x, tableLocationOnScreen.y + topY + myToolBarPanelBounds.y, myToolBarPanelBounds.width, myToolBarPanelBounds.height);
}
}
use of java.awt.event.MouseEvent in project android by JetBrains.
the class WorkBenchTest method fireButtonDragged.
private void fireButtonDragged(@NotNull JComponent dragImage, int xStart, int yStart, int x, int y) {
AbstractButton button = myToolWindow1.getMinimizedButton();
MouseEvent mouseEvent = new MouseEvent(button, MouseEvent.MOUSE_DRAGGED, 1, InputEvent.BUTTON1_MASK, x, y, 1, false);
DragEvent event = new DragEvent(mouseEvent, dragImage, new Point(xStart, yStart));
myToolWindow1.fireButtonDragged(event);
}
Aggregations