if (Gdx.input.isTouched()) { float x = Gdx.input.getX(); float y = Gdx.input.getY(); float yR = viewport.height / (y - viewport.y); // the y ratio y = 480 / yR; float xR = viewport.width / (x - viewport.x); // the x ratio x = 800 / xR; bubbles.add(new Bubble(x, 480 - y)); }
getServer().getPluginManager().registerEvents(this, new Bubble());
public static final Dimension PREF_SIZE = new Dimension(70, 70); //in main method or you can override `getPreferredSize()` Bubble bub = new Bubble(50, 50); bub.setPreferredSize(PREF_SIZE);
import java.awt.Color; import java.awt.Graphics; import java.util.ArrayList; import java.util.List; import javax.swing.JPanel; public class BubblePanel extends JPanel { private final List<Bubble> bubbles; public BubblePanel() { bubbles = new ArrayList<>(); for (int rowIndex = 0; rowIndex < 10; rowIndex++) for (int columnIndex = 0; columnIndex < 20; columnIndex++) bubbles.add(new Bubble(100 + columnIndex * 60, 100 + rowIndex * 60, 28, Color.YELLOW)); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); for (final Bubble bubble : bubbles) bubble.paintComponent(g); } }
public void onDraw(Canvas c) { Bubble b = new Bubble(); p.setColor(b.getColor()); p.setStyle(Paint.Style.FILL); bList.add(b); c.drawCircle(b.getX(), b.getY(), b.getR(), p); // c == null here! }
public Rule parseRule(CompiledDefinition compiledDef, String contents, Source source) { errors = java.util.Collections.synchronizedSet(Sets.newHashSet()); gen = new RuleGrammarGenerator(compiledDef.kompiledDefinition); ParseInModule parser = RuleGrammarGenerator .getCombinedGrammar(gen.getRuleGrammar(compiledDef.executionModule()), isStrict); try (Scanner scanner = parser.getScanner()) { //required for Windows. java.util.Set<K> res = performParse(new HashMap<>(), parser, scanner, new Bubble("rule", contents, Att().add("contentStartLine", Integer.class, 1) .add("contentStartColumn", Integer.class, 1).add(Source.class, source))) .collect(Collectors.toSet()); if (!errors.isEmpty()) { throw errors.iterator().next(); } return upRule(res.iterator().next()); } }