1 /* 2 * The contents of this file are subject to the terms of the Common Development 3 * and Distribution License (the License). You may not use this file except in 4 * compliance with the License. 5 * 6 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html 7 * or http://www.netbeans.org/cddl.txt. 8 * 9 * When distributing Covered Code, include this CDDL Header Notice in each file 10 * and include the License file at http://www.netbeans.org/cddl.txt. 11 * If applicable, add the following below the CDDL Header, with the fields 12 * enclosed by brackets [] replaced by your own identifying information: 13 * "Portions Copyrighted [year] [name of copyright owner]" 14 * 15 * The Original Software is NetBeans. The Initial Developer of the Original 16 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun 17 * Microsystems, Inc. All Rights Reserved. 18 */ 19 20 package org.netbeans.editor.view.spi; 21 22 import java.awt.Graphics; 23 import java.awt.Shape; 24 import javax.swing.event.DocumentEvent; 25 import javax.swing.text.AttributeSet; 26 import javax.swing.text.BadLocationException; 27 import javax.swing.text.Document; 28 import javax.swing.text.Element; 29 import javax.swing.text.Position; 30 import javax.swing.text.View; 31 import javax.swing.text.ViewFactory; 32 33 /** 34 * View providing an access to the {@link ViewRenderingContext} 35 * in the view hierarchy. 36 * 37 * <p> 38 * Accessing of the <code>ViewRenderingContext</code> 39 * from a <code>view</code> must always be done like this:<pre> 40 * 41 * RenderingContextView rcView = RenderingContextView.get(view); 42 * if (rcView != null) { 43 * rcView.acquireRenderingContext(); 44 * try { 45 * ... 46 * } finally { 47 * rcView.releaseRenderingContext(); 48 * } 49 * } 50 * </pre> 51 * 52 * <p> 53 * Only one thread at the time can safely access methods 54 * of the <code>RenderingContextView</code>. It does not have 55 * to be event dispatch thread. 56 * 57 * @author Miloslav Metelka 58 * @version 1.00 59 */ 60 61 public interface RenderingContextView { 62 63 /** 64 * Acquire an instance of rendering context. 65 * After use it must be released by {@link #releaseContext()}. 66 * @param v view for which the rendering context is being obtained. 67 */ 68 public ViewRenderingContext acquireRenderingContext(View v); 69 70 /** 71 * Release rendering context previously acquired by 72 * {@link #acquireRenderingContext(javax.swing.text.View)}. 73 * @param vrc rendering context to be released. 74 */ 75 public void releaseRenderingContext(ViewRenderingContext vrc); 76 77 } 78