public GlancePanel(Project project, FileEditor fileEditor, JPanel container, TaskRunner runner) { this.runner = runner; this.editor = ((TextEditor) fileEditor).getEditor(); this.container = container; this.project = project; container.addComponentListener( componentListener = new ComponentAdapter() { @Override public void componentResized(ComponentEvent componentEvent) { updateSize(); GlancePanel.this.revalidate(); GlancePanel.this.repaint(); } }); editor .getDocument() .addDocumentListener( documentListener = new DocumentAdapter() { @Override public void documentChanged(DocumentEvent documentEvent) { updateImage(); } }); configService.add( configChangeListener = new ConfigChangeListener() { @Override public void configChanged() { readConfig(); updateImage(); updateSize(); GlancePanel.this.revalidate(); GlancePanel.this.repaint(); } }); addMouseWheelListener(mouseWheelListener); readConfig(); editor.getScrollingModel().addVisibleAreaListener(this); editor .getSelectionModel() .addSelectionListener( selectionListener = new SelectionListener() { @Override public void selectionChanged(SelectionEvent selectionEvent) { repaint(); } }); addMouseListener(mouseListener); addMouseMotionListener(mouseListener); updateSize(); for (int i = 0; i < Array.getLength(minimaps); i++) { minimaps[i] = new Minimap(configService.getState()); } updateImage(); }
private void readConfig() { config = configService.getState(); coords.setPixelsPerLine(config.pixelsPerLine); viewportColor = Color.decode("#" + config.viewportColor); }