Search Results

Search found 37239 results on 1490 pages for 'javax swing text'.

Page 54/1490 | < Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >

  • Element to string in HTMLDocument

    - by kalpesh
    i have a Element object its a HTMLDocument object and i want to string value of this element. i want this result Christina Toth, Pharm. D. ======================= plz see below code. public static void main(String args[]) throws Exception { InputStream is = Nullsoft.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); HTMLEditorKit htmlKit = new HTMLEditorKit(); HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument(); HTMLEditorKit.Parser parser = new ParserDelegator(); HTMLEditorKit.ParserCallback callback = htmlDoc.getReader(0); parser.parse(br, callback, true); // Parse ElementIterator iterator = new ElementIterator(htmlDoc); Element element; while ((element = iterator.next()) != null) { AttributeSet attributes = element.getAttributes(); Object name = attributes.getAttribute(StyleConstants.NameAttribute); if ((name instanceof HTML.Tag) && ((name == HTML.Tag.DIV) || (name == HTML.Tag.H2) || (name == HTML.Tag.H3))) { StringBuffer text = new StringBuffer(); int count = element.getElementCount(); for (int i = 0; i < count; i++) { Element child = element.getElement(i); AttributeSet childAttributes = child.getAttributes(); // if (childAttributes.getAttribute(StyleConstants.NameAttribute) == HTML.Tag.CONTENT) { int startOffset = child.getStartOffset(); int endOffset = child.getEndOffset(); int length = endOffset - startOffset; text.append(htmlDoc.getText(startOffset, length)); } } System.out.println(name + ": " + text.toString()); } } System.exit(0); } public static InputStream getInputStream() { String text = "<html>\n" + "<head>\n" + "<title>pg_0001</title>\n" + "\n" + "<style type=\"text/css\">\n" + ".ft3{font-style:normal;font-weight:bold;font-size:11px;font-family:Helvetica;color:#000000;}\n" + "</style>\n" + "</head>\n" + "<body vlink=\"#FFFFFF\" link=\"#FFFFFF\" bgcolor=\"#ffffff\">\n" + "\n" + "\n" + "<div style=\"position:absolute;top:597;left:252\"><nobr><span class=\"ft3\">Christina Toth, Pharm. D.</span></nobr></div>\n" + "\n" + "\n" + "</body>\n" + "</html>"; InputStream is = null; try { is = new ByteArrayInputStream(text.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return is; }

    Read the article

  • VB.NET - using textfile as source for menus and textboxes

    - by Kenny Bones
    Hi, this is probably a bit tense and I'm not sure if this is possible at all. But basically, I'm trying to create a small application which contains alot of PowerShell-code which I want to run in an easy matter. I've managed to create everything myself and it does work. But all of the PowerShell code is manually hardcoded and this gives me a huge disadvantage. What I was thinking was creating some sort of dynamic structure where I can read a couple of text files (possible a numerous amount of text files) and use these as the source for both the comboboxes and the richtextbox which provovides as the string used to run in PowerShell. I was thinking something like this: Combobox - "Choose cmdlet" - Use "menucode.txt" as source Richtextbox - Use "code.txt" as source But, the thing is, Powershell snippets need a few arguments in order for them to work. So I've got a couple of comboboxes and a few textboxes which provides as input for these arguments. And this is done manually as it is right now. So rewriting this small application should also search the textfile for some keywords and have the comboboxes and textboxes to replace those keywords. And I'm not sure how to do this. So, would this requre a whole lot of textfiles? Or could I use one textfile and separate each PowerShell cmdlet snippets with something? Like some sort of a header? Right now, I've got this code at the eventhandler (ComboBox_SelectedIndexChanged) If ComboBoxFunksjon.Text = "Set attribute" Then TxtBoxUsername.Visible = True End If If chkBoxTextfile.Checked = True Then If txtboxBrowse.Text = "" Then MsgBox("You haven't choses a textfile as input for usernames") End If LabelAttribute.Visible = True LabelUsername.Visible = False ComboBoxAttribute.Visible = True TxtBoxUsername.Visible = False txtBoxCode.Text = "$users = Get-Content " & txtboxBrowse.Text & vbCrLf & "foreach ($a in $users)" & vbCrLf & "{" & vbCrLf & "Set-QADUser -Identity $a -ObjectAttributes @{" & ComboBoxAttribute.SelectedItem & "='" & TxtBoxValue.Text & "'}" & vbCrLf & "}" If ComboBoxAttribute.SelectedItem = "Outlook WebAccess" Then TxtBoxValue.Visible = False CheckBoxValue.Visible = True CheckBoxValue.Text = "OWA Enabled?" txtBoxCode.Text = "$users = Get-Content " & txtboxBrowse.Text & vbCrLf & "foreach ($a in $users)" & vbCrLf & "{" & vbCrLf & "Set-CASMailbox -Identity $a -OWAEnabled" & " " & "$" & CheckBoxValue.Checked & " '}" & vbCrLf & "}" End If If ComboBoxAttribute.SelectedItem = "MobileSync" Then TxtBoxValue.Visible = False CheckBoxValue.Visible = True CheckBoxValue.Text = "MobileSync Enabled?" Dim value If CheckBoxValue.Checked = True Then value = "0" Else value = "7" End If txtBoxCode.Text = "$users = Get-Content " & txtboxBrowse.Text & vbCrLf & "foreach ($a in $users)" & vbCrLf & "{" & vbCrLf & "Set-QADUser -Identity $a -ObjectAttributes @{msExchOmaAdminWirelessEnable='" & value & " '}" & vbCrLf & "}" End If Else LabelAttribute.Visible = True LabelUsername.Visible = True ComboBoxAttribute.Visible = True txtBoxCode.Text = "Set-QADUser -Identity " & TxtBoxUsername.Text & " -ObjectAttributes @{" & ComboBoxAttribute.SelectedItem & "='" & TxtBoxValue.Text & " '}" If ComboBoxAttribute.SelectedItem = "Outlook WebAccess" Then TxtBoxValue.Visible = False CheckBoxValue.Visible = True CheckBoxValue.Text = "OWA Enabled?" txtBoxCode.Text = "Set-CASMailbox " & TxtBoxUsername.Text & " -OWAEnabled " & "$" & CheckBoxValue.Checked End If If ComboBoxAttribute.SelectedItem = "MobileSync" Then TxtBoxValue.Visible = False CheckBoxValue.Visible = True CheckBoxValue.Text = "MobileSync Enabled?" Dim value If CheckBoxValue.Checked = True Then value = "0" Else value = "7" End If txtBoxCode.Text = "Set-QADUser " & TxtBoxUsername.Text & " -ObjectAttributes @{msExchOmaAdminWirelessEnable='" & value & "'}" End If End If Now, this snippet above lets me either use a text file as a source for each username used in the powershell snippet. Just so you know :) And I know, this is probably coded as stupidly as it gets. But it does work! :)

    Read the article

  • how to get selected chracter position in JTextArea?

    - by Reddy
    Hi! Here is a challenging question! Let me first tell you my scenario how am i implementing a solution to a problem. I am reading a log file and displaying it on the JTextArea. Log file is cp037 character coded. I was reading each file as a byte stream or byte array from the log file & displaying it. Anyways, i managed to display the text properly in JTextArea by cp037 character coding. Now, User may select a set of characters in the JTextArea. All i want is the position of first character of the user's selected text, from a nearest special character '+'(its character code in cp037 is 4E), which is prior to the selected text. This character may occur at several places in the JTextArea. In simple sentence, i want the first character location(of user selected text) from nearset '+' which should be occuring prior to the user's selected text. PS: cp037 is a type of character encoding scheme which is created by IBM & used for IBM Mainframes. Please fell free to ask me if the question is not clear...:-

    Read the article

  • Writing a line in a JTextArea from another class

    - by Christopher Nastovski
    I'm trying to use a Method in my class 'Visual' to write a line of code into a JTextArea and it prints when I call it from 'Visual' but when I call it from 'Login' It only prints Text into the Console, not to the TextArea. private static Visual Visual; Visual.WriteLine("I'm sorry, your username or password is incorrect. Please try again."); or private static Visual Visual = new Visual(); Visual.WriteLine("I'm sorry, your username or password is incorrect. Please try again."); Dont work form 'Login' But, WriteLine("Test"); works from 'Visual', the class that the method is in. Here's the method in 'Visual' public void WriteLine(String Text) { System.out.println(Text); SystemFeed.append(Text.toString() + "\n"); SystemFeed.setCaretPosition(SystemFeed.getDocument().getLength()); }

    Read the article

  • JLabel transparency problem

    - by Rendicahya
    I have a dark-gray JPanel with a JLabel on it. I set new Color(0, 0, 0, .5f) (tranparent) as the background of the JLabel and I change the text several times using a button. The problem is, everytime the text is changed, the previous text still remains behind the new text. I change the text from "123456789" to "1234567", "12345" and "123". Here is the screenshot: How do I get rid of this "shadow"? Here's the code: public class TransparentJLabel extends JFrame { private int i = 0; private String[] value = {"123456789", "1234567", "12345", "123", "1"}; public TransparentJLabel() { setSize(300, 160); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setLayout(null); JPanel panel = new JPanel(); panel.setBackground(new Color(102, 102, 102)); panel.setLayout(null); panel.setBounds(0, 0, 300, 160); final JLabel label = new JLabel(); label.setText(value[0]); label.setFont(new Font("Times New Roman", 1, 36)); label.setForeground(new Color(255, 255, 255)); label.setBackground(new Color(0, 0, 0, .5f)); label.setHorizontalAlignment(SwingConstants.CENTER); label.setOpaque(true); label.setBounds(10, 10, 270, 70); JButton button = new JButton(); button.setText("Change"); button.setBounds(100, 90, 90, 25); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { label.setText(value[++i]); } }); panel.add(label); panel.add(button); add(panel); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { new TransparentJLabel().setVisible(true); } }); } }

    Read the article

  • String on a model

    - by alecnash
    I am trying to put a sting on a Model and I want it to be dynamic. Did some research and came up with drawing the text on the texture and then set it on the model. I use something like this: public static Texture2D SpriteFontTextToTexture(SpriteFont font, string text, Color backgroundColor, Color textColor) { Size = font.MeasureString(text); RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice, (int)Size.X, (int)Size.Y); GraphicsDevice.SetRenderTarget(renderTarget); GraphicsDevice.Clear(Color.Transparent); Spritbatch.Begin(); //have to redo the ColorTexture Spritbatch.Draw(ColorTexture.Create(GraphicsDevice, 1024, 1024, backgroundColor), Vector2.Zero, Color.White); Spritbatch.DrawString(font, text, Vector2.Zero, textColor); Spritbatch.End(); GraphicsDevice.SetRenderTarget(null); return renderTarget; } When I was working with primitives and not models everything worked fine because I set the texture exactly where I wanted but with the model (RoundedRect 3d button) it looks like that: Is there a way to have the text centered only on one side?

    Read the article

  • Java Swing Forms Catching Data

    - by RhigoHR
    Hi everybody, I have a form in swing with a lot of textfields receiving data, then, the idea is when a click on a botton, the app catch all the data from the textfields. Do you know a good practice for this?, or is it necessary to catch textfield by textfield to get the data?.. Thx for your time.

    Read the article

  • Java projects without swing

    - by Jeff Home
    I'm quite familiar with Java and I would like to work on a project on my free time but for some reason, I just hate having to work with swing. I'm wondering what kind of Java technologies are available out there that I can use for starting a project. Thank you.

    Read the article

  • How I can add JScroll bar to NavigableImagePanel which is an Image panel with an small navigation vi

    - by Sarah Kho
    Hi, I have the following NavigableImagePanel, it is under BSD license and I found it in the web. What I want to do with this panel is as follow: I want to add a JScrollPane to it in order to show images in their full size and let the users to re-center the image using the small navigation panel. Right now, the panel resize the images to fit them in the current panel size. I want it to load the image in its real size and let users to navigate to different parts of the image using the navigation panel. Source code for the panel: import java.awt.AWTEvent; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.Toolkit; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.Arrays; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingUtilities; /** * @author pxt * */ public class NavigableImagePanel extends JPanel { /** * <p>Identifies a change to the zoom level.</p> */ public static final String ZOOM_LEVEL_CHANGED_PROPERTY = "zoomLevel"; /** * <p>Identifies a change to the zoom increment.</p> */ public static final String ZOOM_INCREMENT_CHANGED_PROPERTY = "zoomIncrement"; /** * <p>Identifies that the image in the panel has changed.</p> */ public static final String IMAGE_CHANGED_PROPERTY = "image"; private static final double SCREEN_NAV_IMAGE_FACTOR = 0.15; // 15% of panel's width private static final double NAV_IMAGE_FACTOR = 0.3; // 30% of panel's width private static final double HIGH_QUALITY_RENDERING_SCALE_THRESHOLD = 1.0; private static final Object INTERPOLATION_TYPE = RenderingHints.VALUE_INTERPOLATION_BILINEAR; private double zoomIncrement = 0.2; private double zoomFactor = 1.0 + zoomIncrement; private double navZoomFactor = 1.0 + zoomIncrement; private BufferedImage image; private BufferedImage navigationImage; private int navImageWidth; private int navImageHeight; private double initialScale = 0.0; private double scale = 0.0; private double navScale = 0.0; private int originX = 0; private int originY = 0; private Point mousePosition; private Dimension previousPanelSize; private boolean navigationImageEnabled = true; private boolean highQualityRenderingEnabled = true; private WheelZoomDevice wheelZoomDevice = null; private ButtonZoomDevice buttonZoomDevice = null; /** * <p>Defines zoom devices.</p> */ public static class ZoomDevice { /** * <p>Identifies that the panel does not implement zooming, * but the component using the panel does (programmatic zooming method).</p> */ public static final ZoomDevice NONE = new ZoomDevice("none"); /** * <p>Identifies the left and right mouse buttons as the zooming device.</p> */ public static final ZoomDevice MOUSE_BUTTON = new ZoomDevice("mouseButton"); /** * <p>Identifies the mouse scroll wheel as the zooming device.</p> */ public static final ZoomDevice MOUSE_WHEEL = new ZoomDevice("mouseWheel"); private String zoomDevice; private ZoomDevice(String zoomDevice) { this.zoomDevice = zoomDevice; } public String toString() { return zoomDevice; } } //This class is required for high precision image coordinates translation. private class Coords { public double x; public double y; public Coords(double x, double y) { this.x = x; this.y = y; } public int getIntX() { return (int)Math.round(x); } public int getIntY() { return (int)Math.round(y); } public String toString() { return "[Coords: x=" + x + ",y=" + y + "]"; } } private class WheelZoomDevice implements MouseWheelListener { public void mouseWheelMoved(MouseWheelEvent e) { Point p = e.getPoint(); boolean zoomIn = (e.getWheelRotation() < 0); if (isInNavigationImage(p)) { if (zoomIn) { navZoomFactor = 1.0 + zoomIncrement; } else { navZoomFactor = 1.0 - zoomIncrement; } zoomNavigationImage(); } else if (isInImage(p)) { if (zoomIn) { zoomFactor = 1.0 + zoomIncrement; } else { zoomFactor = 1.0 - zoomIncrement; } zoomImage(); } } } private class ButtonZoomDevice extends MouseAdapter { public void mouseClicked(MouseEvent e) { Point p = e.getPoint(); if (SwingUtilities.isRightMouseButton(e)) { if (isInNavigationImage(p)) { navZoomFactor = 1.0 - zoomIncrement; zoomNavigationImage(); } else if (isInImage(p)) { zoomFactor = 1.0 - zoomIncrement; zoomImage(); } } else { if (isInNavigationImage(p)) { navZoomFactor = 1.0 + zoomIncrement; zoomNavigationImage(); } else if (isInImage(p)) { zoomFactor = 1.0 + zoomIncrement; zoomImage(); } } } } /** * <p>Creates a new navigable image panel with no default image and * the mouse scroll wheel as the zooming device.</p> */ public NavigableImagePanel() { setOpaque(false); addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { if (scale > 0.0) { if (isFullImageInPanel()) { centerImage(); } else if (isImageEdgeInPanel()) { scaleOrigin(); } if (isNavigationImageEnabled()) { createNavigationImage(); } repaint(); } previousPanelSize = getSize(); } }); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) { if (isInNavigationImage(e.getPoint())) { Point p = e.getPoint(); displayImageAt(p); } } } public void mouseClicked(MouseEvent e){ if (e.getClickCount() == 2) { resetImage(); } } }); addMouseMotionListener(new MouseMotionListener() { public void mouseDragged(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && !isInNavigationImage(e.getPoint())) { Point p = e.getPoint(); moveImage(p); } } public void mouseMoved(MouseEvent e) { //we need the mouse position so that after zooming //that position of the image is maintained mousePosition = e.getPoint(); } }); setZoomDevice(ZoomDevice.MOUSE_WHEEL); } /** * <p>Creates a new navigable image panel with the specified image * and the mouse scroll wheel as the zooming device.</p> */ public NavigableImagePanel(BufferedImage image) throws IOException { this(); setImage(image); } private void addWheelZoomDevice() { if (wheelZoomDevice == null) { wheelZoomDevice = new WheelZoomDevice(); addMouseWheelListener(wheelZoomDevice); } } private void addButtonZoomDevice() { if (buttonZoomDevice == null) { buttonZoomDevice = new ButtonZoomDevice(); addMouseListener(buttonZoomDevice); } } private void removeWheelZoomDevice() { if (wheelZoomDevice != null) { removeMouseWheelListener(wheelZoomDevice); wheelZoomDevice = null; } } private void removeButtonZoomDevice() { if (buttonZoomDevice != null) { removeMouseListener(buttonZoomDevice); buttonZoomDevice = null; } } /** * <p>Sets a new zoom device.</p> * * @param newZoomDevice specifies the type of a new zoom device. */ public void setZoomDevice(ZoomDevice newZoomDevice) { if (newZoomDevice == ZoomDevice.NONE) { removeWheelZoomDevice(); removeButtonZoomDevice(); } else if (newZoomDevice == ZoomDevice.MOUSE_BUTTON) { removeWheelZoomDevice(); addButtonZoomDevice(); } else if (newZoomDevice == ZoomDevice.MOUSE_WHEEL) { removeButtonZoomDevice(); addWheelZoomDevice(); } } /** * <p>Gets the current zoom device.</p> */ public ZoomDevice getZoomDevice() { if (buttonZoomDevice != null) { return ZoomDevice.MOUSE_BUTTON; } else if (wheelZoomDevice != null) { return ZoomDevice.MOUSE_WHEEL; } else { return ZoomDevice.NONE; } } //Called from paintComponent() when a new image is set. private void initializeParams() { double xScale = (double)getWidth() / image.getWidth(); double yScale = (double)getHeight() / image.getHeight(); initialScale = Math.min(xScale, yScale); scale = initialScale; //An image is initially centered centerImage(); if (isNavigationImageEnabled()) { createNavigationImage(); } } //Centers the current image in the panel. private void centerImage() { originX = (int)(getWidth() - getScreenImageWidth()) / 2; originY = (int)(getHeight() - getScreenImageHeight()) / 2; } //Creates and renders the navigation image in the upper let corner of the panel. private void createNavigationImage() { //We keep the original navigation image larger than initially //displayed to allow for zooming into it without pixellation effect. navImageWidth = (int)(getWidth() * NAV_IMAGE_FACTOR); navImageHeight = navImageWidth * image.getHeight() / image.getWidth(); int scrNavImageWidth = (int)(getWidth() * SCREEN_NAV_IMAGE_FACTOR); int scrNavImageHeight = scrNavImageWidth * image.getHeight() / image.getWidth(); navScale = (double)scrNavImageWidth / navImageWidth; navigationImage = new BufferedImage(navImageWidth, navImageHeight, image.getType()); Graphics g = navigationImage.getGraphics(); g.drawImage(image, 0, 0, navImageWidth, navImageHeight, null); } /** * <p>Sets an image for display in the panel.</p> * * @param image an image to be set in the panel */ public void setImage(BufferedImage image) { BufferedImage oldImage = this.image; this.image = image; //Reset scale so that initializeParameters() is called in paintComponent() //for the new image. scale = 0.0; firePropertyChange(IMAGE_CHANGED_PROPERTY, (Image)oldImage, (Image)image); repaint(); } /** * <p>resets an image to the centre of the panel</p> * */ public void resetImage() { BufferedImage oldImage = this.image; this.image = image; //Reset scale so that initializeParameters() is called in paintComponent() //for the new image. scale = 0.0; firePropertyChange(IMAGE_CHANGED_PROPERTY, (Image)oldImage, (Image)image); repaint(); } /** * <p>Tests whether an image uses the standard RGB color space.</p> */ public static boolean isStandardRGBImage(BufferedImage bImage) { return bImage.getColorModel().getColorSpace().isCS_sRGB(); } //Converts this panel's coordinates into the original image coordinates private Coords panelToImageCoords(Point p) { return new Coords((p.x - originX) / scale, (p.y - originY) / scale); } //Converts the original image coordinates into this panel's coordinates private Coords imageToPanelCoords(Coords p) { return new Coords((p.x * scale) + originX, (p.y * scale) + originY); } //Converts the navigation image coordinates into the zoomed image coordinates private Point navToZoomedImageCoords(Point p) { int x = p.x * getScreenImageWidth() / getScreenNavImageWidth(); int y = p.y * getScreenImageHeight() / getScreenNavImageHeight(); return new Point(x, y); } //The user clicked within the navigation image and this part of the image //is displayed in the panel. //The clicked point of the image is centered in the panel. private void displayImageAt(Point p) { Point scrImagePoint = navToZoomedImageCoords(p); originX = -(scrImagePoint.x - getWidth() / 2); originY = -(scrImagePoint.y - getHeight() / 2); repaint(); } //Tests whether a given point in the panel falls within the image boundaries. private boolean isInImage(Point p) { Coords coords = panelToImageCoords(p); int x = coords.getIntX(); int y = coords.getIntY(); return (x >= 0 && x < image.getWidth() && y >= 0 && y < image.getHeight()); } //Tests whether a given point in the panel falls within the navigation image //boundaries. private boolean isInNavigationImage(Point p) { return (isNavigationImageEnabled() && p.x < getScreenNavImageWidth() && p.y < getScreenNavImageHeight()); } //Used when the image is resized. private boolean isImageEdgeInPanel() { if (previousPanelSize == null) { return false; } return (originX > 0 && originX < previousPanelSize.width || originY > 0 && originY < previousPanelSize.height); } //Tests whether the image is displayed in its entirety in the panel. private boolean isFullImageInPanel() { return (originX >= 0 && (originX + getScreenImageWidth()) < getWidth() && originY >= 0 && (originY + getScreenImageHeight()) < getHeight()); } /** * <p>Indicates whether the high quality rendering feature is enabled.</p> * * @return true if high quality rendering is enabled, false otherwise. */ public boolean isHighQualityRenderingEnabled() { return highQualityRenderingEnabled; } /** * <p>Enables/disables high quality rendering.</p> * * @param enabled enables/disables high quality rendering */ public void setHighQualityRenderingEnabled(boolean enabled) { highQualityRenderingEnabled = enabled; } //High quality rendering kicks in when when a scaled image is larger //than the original image. In other words, //when image decimation stops and interpolation starts. private boolean isHighQualityRendering() { return (highQualityRenderingEnabled && scale > HIGH_QUALITY_RENDERING_SCALE_THRESHOLD); } /** * <p>Indicates whether navigation image is enabled.<p> * * @return true when navigation image is enabled, false otherwise. */ public boolean isNavigationImageEnabled() { return navigationImageEnabled; } /** * <p>Enables/disables navigation with the navigation image.</p> * <p>Navigation image should be disabled when custom, programmatic navigation * is implemented.</p> * * @param enabled true when navigation image is enabled, false otherwise. */ public void setNavigationImageEnabled(boolean enabled) { navigationImageEnabled = enabled; repaint(); } //Used when the panel is resized private void scaleOrigin() { originX = originX * getWidth() / previousPanelSize.width; originY = originY * getHeight() / previousPanelSize.height; repaint(); } //Converts the specified zoom level to scale. private double zoomToScale(double zoom) { return initialScale * zoom; } /** * <p>Gets the current zoom level.</p> * * @return the current zoom level */ public double getZoom() { return scale / initialScale; } /** * <p>Sets the zoom level used to display the image.</p> * <p>This method is used in programmatic zooming. The zooming center is * the point of the image closest to the center of the panel. * After a new zoom level is set the image is repainted.</p> * * @param newZoom the zoom level used to display this panel's image. */ public void setZoom(double newZoom) { Point zoomingCenter = new Point(getWidth() / 2, getHeight() / 2); setZoom(newZoom, zoomingCenter); } /** * <p>Sets the zoom level used to display the image, and the zooming center, * around which zooming is done.</p> * <p>This method is used in programmatic zooming. * After a new zoom level is set the image is repainted.</p> * * @param newZoom the zoom level used to display this panel's image. */ public void setZoom(double newZoom, Point zoomingCenter) { Coords imageP = panelToImageCoords(zoomingCenter); if (imageP.x < 0.0) { imageP.x = 0.0; } if (imageP.y < 0.0) { imageP.y = 0.0; } if (imageP.x >= image.getWidth()) { imageP.x = image.getWidth() - 1.0; } if (imageP.y >= image.getHeight()) { imageP.y = image.getHeight() - 1.0; } Coords correctedP = imageToPanelCoords(imageP); double oldZoom = getZoom(); scale = zoomToScale(newZoom); Coords panelP = imageToPanelCoords(imageP); originX += (correctedP.getIntX() - (int)panelP.x); originY += (correctedP.getIntY() - (int)panelP.y); firePropertyChange(ZOOM_LEVEL_CHANGED_PROPERTY, new Double(oldZoom), new Double(getZoom())); repaint(); } /** * <p>Gets the current zoom increment.</p> * * @return the current zoom increment */ public double getZoomIncrement() { return zoomIncrement; } /** * <p>Sets a new zoom increment value.</p> * * @param newZoomIncrement new zoom increment value */ public void setZoomIncrement(double newZoomIncrement) { double oldZoomIncrement = zoomIncrement; zoomIncrement = newZoomIncrement; firePropertyChange(ZOOM_INCREMENT_CHANGED_PROPERTY, new Double(oldZoomIncrement), new Double(zoomIncrement)); } //Zooms an image in the panel by repainting it at the new zoom level. //The current mouse position is the zooming center. private void zoomImage() { Coords imageP = panelToImageCoords(mousePosition); double oldZoom = getZoom(); scale *= zoomFactor; Coords panelP = imageToPanelCoords(imageP); originX += (mousePosition.x - (int)panelP.x); originY += (mousePosition.y - (int)panelP.y); firePropertyChange(ZOOM_LEVEL_CHANGED_PROPERTY, new Double(oldZoom), new Double(getZoom())); repaint(); } //Zooms the navigation image private void zoomNavigationImage() { navScale *= navZoomFactor; repaint(); } /** * <p>Gets the image origin.</p> * <p>Image origin is defined as the upper, left corner of the image in * the panel's coordinate system.</p> * @return the point of the upper, left corner of the image in the panel's coordinates * system. */ public Point getImageOrigin() { return new Point(originX, originY); } /** * <p>Sets the image origin.</p> * <p>Image origin is defined as the upper, left corner of the image in * the panel's coordinate system. After a new origin is set, the image is repainted. * This method is used for programmatic image navigation.</p>

    Read the article

  • SQL SERVER – FT_IFTS_SCHEDULER_IDLE_WAIT – Full Text – Wait Type – Day 13 of 28

    - by pinaldave
    In the last few days during this series, I got many question about this Wait type. It would be great if you read my original related wait stats query in the first post because I have filtered it out in WHERE clause. However, I still get questions about this being one of the most wait types they encounter. The truth is, this is a background task processing and it really does not matter and it should be filtered out. There are many new Wait types related to Full Text Search that are introduced in SQL Server 2008. If you run the following query, you will be able to find them in the list. Currently there is not enough information for all of them available on BOL or any other place. But don’t worry; I will write an in-depth article when I learn more about them. SELECT * FROM sys.dm_os_wait_stats WHERE wait_type LIKE 'FT_%' The result set will contain following rows. FT_RESTART_CRAWL FT_METADATA_MUTEX FT_IFTSHC_MUTEX FT_IFTSISM_MUTEX FT_IFTS_RWLOCK FT_COMPROWSET_RWLOCK FT_MASTER_MERGE FT_IFTS_SCHEDULER_IDLE_WAIT We have understood so far that there is not much information available. But the problem is when you have this Wait type, what should you do?  The answer is to filter them out for the moment (i.e, do not pay attention on them) and focus on other pressing issues in wait stats or performance tuning. Here are two of my informal suggestions, which are totally independent from wait stats: Turn off the Full Text Search service in your system if you are  not necessarily using it on your server. Learn proper Full Text Search methodology. You can get Michael Coles’ book: Pro Full-Text Search in SQL Server 2008. Now I invite you to speak out your suggestions or any input regarding Full Text-related best practices and wait stats issue. Please leave a comment. Note: The information presented here is from my experience and there is no way that I claim it to be accurate. I suggest reading Book OnLine for further clarification. All the discussions of Wait Stats in this blog are generic and vary from system to system. It is recommended that you test this on a development server before implementing it to a production server. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, PostADay, SQL, SQL Authority, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, SQL Wait Stats, SQL Wait Types, T SQL, Technology

    Read the article

  • Passing text message to web page from web user control

    - by Narendra Tiwari
    Here is a brief summary how we can send a text message to webpage by a web user control. Delegates is the slolution. There are many good articles on .net delegates you can refer some of them below. The scenario is we want to send a text message to the page on completion of some activity on webcontrol. 1/ Create a Base class for webcontrol (refer code below), assuming we are passing some text messages to page from web user control  - Declare a delegate  - Declare an event of type delegate using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; //Declaring delegate with message parameter public delegate void SendMessageToThePageHandler(string messageToThePage); public         } class ControlBase: System.Web.UI.UserControl { public ControlBase() { // TODO: Add constructor logic here }protected override void OnInit(EventArgs e) { base.OnInit(e); }private string strMessageToPass;/// <summary> /// MessageToPass - Property to pass text message to page /// </summary> public string MessageToPass { get { return strMessageToPass; } set { strMessageToPass = value; } }/// <summary> /// SendMessageToPage - Called from control to invoke the event /// </summary> /// <param name="strMessage">Message to pass</param> public void SendMessageToPage(string strMessage) {   if (this.sendMessageToThePage != null)       this.sendMessageToThePage(strMessage); } 2/ Register events on webpage on page Load eventthis.AddControlEventHandler((ControlBase)WebUserControl1); this.AddControlEventHandler((ControlBase)WebUserControl2); /// <summary> /// AddControlEventHandler- Hooking web user control event /// </summary> /// <param name="ctrl"></param> private void AddControlEventHandler(ControlBase ctrl) { ctrl.sendMessageToThePage += delegate(string strMessage) {   //display message   lblMessage.Text = strMessage; }; } References: http://www.akadia.com/services/dotnet_delegates_and_events.html     3/

    Read the article

  • Controlling text that appears in google search results

    - by Mick
    I have recently made a simple (pure HTML) website. The most important key phrase that I want to capture is "full reserve banking". Currently, if I type "full reserve banking" (without quotes) into google, then my site appears as the 7th item on the first page. I am reasonably happy with this as the site is so new. But one frustration is that the text that google displays in relation to my site is rather misleading. The main message I would like to get across is that my site is "A collection of resources for anyone interested in this alternative monetary system." and I have this as the first line of text on the page. Unfortunately, this important sentence is nowhere to be seen in the google search result. So my question is - is there anything I can do to fix this error? Edit: I noticed that someone edited this question to remove the name of the website. I was very keen to leave it in because being able to look at it makes it far easier to diagnose what I did wrong. Indeed the answer suggested by "Su" clearly shows that they looked at my website and analyzed what it was doing which helped them give a clearer answer. If I am breaking some policy by including the name then please explain what this policy is in a comment. Edit: I have now made a series of changes to my meta descriptions as inspired by the answers given here. On the homepage I now have the text: <META NAME="description" CONTENT="A collection of resources for anyone interested in Full Reserve Banking. What it is, how it works, web resources, organisations, research papers etc."> I am now very excited to see what will happen after the next visit by the google robots. Edit: Result! I just did a google search for "full reserve banking", and the text that appeared was: Full Reserve Banking: The definitive resource. A collection of resources for anyone interested in Full Reserve Banking. What it is, how it works, web resources, organisations, research papers etc. www.fullreservebanking.com/ - Cached By the way, I did originally have a meta description - but it was too short, it just said "full reserve banking". Google obviously assumed this was too little and so chose to use its own algorithms to cook up a different sentence from the main text.

    Read the article

  • How to remove a tagged block of text in a file?

    - by EmpireJones
    How can I remove all instances of tagged blocks of text in a file with sed, grep, or another program? If I have a file which contains: random text // START TEXT internal text // END TEXT more random // START TEXT asdf // END TEXT text how can I remove all blocks of text within the start/end lines, produce the following? random text more random text

    Read the article

  • Which are the non-x text editors in Powershell?

    - by Andrei T. Ursan
    Are there some editors like emacs, vi/vim, specifically for power shell, if so which are the best? I will have to do some work on windows and I need some unix productivity - which means for me shell + text editor with syntax highlighting (for python, java, c, c++), so which are my options? Edit: I'm looking for an alternative at vim or other unix editors, and cygwin is not an option. I just want from the command line to say texteditor_name file1, modify it, save it etc, and all of these to happen inside the terminal, not in another interface etc.

    Read the article

  • Vim: Fuzzy file search comparable to Sublime Text 2's?

    - by Jed
    I've tried FuzzyFinder, Command-T, and Ctrl-P (which is my finder of choice right now), but none hold a candle to Sublime Text 2. For example, I want to type: Head.php and have it find, among others: app/code/core/Mage/Page/Block/Html/Head.php Currently in Ctrl-P, which has otherwise served me better than Command-T, searching for Head.php gives me these first: downloader/lib/Mage/Connect/Command/Config_Header.php app/code/local/Namespace/Modals/Helper/Reader.php app/code/core/Mage/XMLConnect/Helper/Ipad.php My file is nowhere to be found (and I've never opened any of the above files), so I have to type this instead: pagehtmlhead.php Is there any utility that does smarter scoring/matching?

    Read the article

  • What is a descriptive name for a web service that responds with plain text?

    - by Rich Shealer
    I'm looking for the proper name for a web service that responds with text as opposed to XML. As an example this "cardServer" service will return 5 cards for a poker hand. http://hostname:8080/cardServer/deal/Game=Poker&Qty=5 The result could look like this: Card1=Ad Card2=Kc Card3=Ts Card4=5d Card5=3d The real world example is not as trivial, but the concept is the same. Parameters if any are passed as POST variables. We currently parse the response into a string list and use the values. The process works just fine. What I'm wondering if this service method has a name that has easier tools to deal with the responses and therefore did we reinvent the wheel? For the record the service was provided and maintained by a customer.

    Read the article

  • What editor/viewer to use to inspect large text based files?

    - by Turismo
    Are there any text editors/viewers (preferably on windows but other platforms are also ok) that can handle files of 500 MB or more? The editors I checked so far (Notepad++, Notepad, Eclipse) all choked on files of that size. Edit: Many thanks for the great suggestions. I tried gvim as it was the top voted and was available on Windows. I opened the file in a reasonable time. After that scrolling and searching was very smooth as long as syntax highlighting was turned off. From the other editors mentioned TextPad and EmEditor both claim to be able to handle large files very well. EmEditor seems to be built exactly for editing large files. I'll probably try both and report back.

    Read the article

  • Dictionary-based text auto-completion in Windows (i.e. Mozilla Thunderbird e-mail client)?

    - by None
    Most programmer's text editors and IDEs have it, automatic completion of the first few characters (letters) of a keyword or function name. Also, most address bars or search fields feature this (like the tag input below the posting form). I would like the same for a few, often-occuring words in business correspondance. Since I could not find an extension for the application in question, Mozilla Thunderbird, I would like to know if there are applications or methods that suggest the complete words from a dictionary like sup per eruser erfluent PS: Here's an article on Wikipedia: Word completion Here's a product for $25: Type Booster Ideally, the solution is free.

    Read the article

< Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >