How to render string in graphics2d by draw pixels for each string....

How do you draw a text of graphics2d onto screen? BUT without using the drawstring method which just prints the text out.
What i basically want is to render the text, one pixel of the text string at a time.
for e.g. say i want to draw the word "hello", what i want is that it starts at letter "H" by drawing pixel of top to bottom at a speed which i can control (latter stuff)

This would be a good starting point:
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
public class PerPixelStringRenderDemo extends JFrame {
     private PerPixelStringRenderPanel cp;
     public PerPixelStringRenderDemo() {
          Font font = new Font("Sans Serif", Font.ITALIC, 48);
          cp = new PerPixelStringRenderPanel(font, "Hello, World!", false);
          cp.setDelay(0, 100);
          setContentPane(cp);
          setTitle("Per-Pixel String Rendering");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          pack();
     public void setVisible(boolean visible) {
          super.setVisible(visible);
          if (visible) {
               cp.start(true);
     public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
               public void run() {
                    new PerPixelStringRenderDemo().setVisible(true);
     private class PerPixelStringRenderPanel extends JPanel implements Runnable {
          private BufferedImage bi;
          private Thread timerThread;
          private int pixelCount, maxPixelCount;
          private int delayMillis, delayNanos;
          private boolean lineOriented;
          public PerPixelStringRenderPanel(Font font, String text,
                                                  boolean lineOriented) {
               this.lineOriented = lineOriented;
               bi = createImage(font, text);
               setDelay(1, 0);
          private BufferedImage createImage(Font font, String text) {
               FontMetrics fm = getFontMetrics(font);
               int width = fm.stringWidth(text);
               int height = fm.getHeight();
               maxPixelCount = width * height;
               BufferedImage bi = new BufferedImage(width, height,
                                                  BufferedImage.TYPE_INT_ARGB);
               setPreferredSize(new Dimension(width, height));
               int y = fm.getAscent();
               Graphics2D g2d = (Graphics2D)bi.createGraphics();
               g2d.setFont(font);
               g2d.setColor(Color.BLACK);
               g2d.drawString(text, 0,y);
               g2d.dispose();
               return bi;
          protected void paintComponent(Graphics g) {
               super.paintComponent(g);
               int w = bi.getWidth();
               int drawnRowCount = pixelCount/w;
               g.drawImage(bi, 0,0,w+1,drawnRowCount+1, 0,0,w+1,drawnRowCount+1,null);
               int remaining = pixelCount%w;
               g.drawImage(bi, 0,drawnRowCount+1, remaining+1,drawnRowCount+2,
                                   0,drawnRowCount+1, remaining+1,drawnRowCount+2,
                                   null);
          public void run() {
               pixelCount = 0;
               while (pixelCount<maxPixelCount) {
                    try {
                         Thread.sleep(delayMillis, delayNanos);
                    } catch (InterruptedException ie) {
                         break; // Thread stopped via interrupt()
                    repaint();
                    pixelCount += lineOriented ? bi.getWidth() : 1;
          public void setDelay(int millis, int nanos) {
               delayMillis = millis;
               delayNanos = nanos;
          public void start(boolean reset) {
               stop();
               if (reset) {
                    pixelCount = 0;
               timerThread = new Thread(this);
               timerThread.start();
          public void stop() {
               if (timerThread!=null) {
                    timerThread.interrupt();
                    try {
                         timerThread.join();
                    } catch (InterruptedException ie) {}
                    timerThread = null;
}It allows you to toggle between drawing one pixel at a time and one row of pixels at a time. If you do the former (what you asked for in this post), you'll have to set the delay pretty low, as it takes longer than you think to draw each pixel individually. If you do the latter, you'll want to set the delay much higher (in the milliseconds), because it's very fast to draw 1 line at a time.

Similar Messages

  • How to find out exact labour hour and expenses for each labour attached to

    Team,
    How to find out exact labour hour and expenses for each labour attached to machine
    We are planning to go with CATS.
    But in Cats how Production Planning department get the exact labour coust
    (which includes labour accomodation building , EB etc. paying by comp)
    How to do this in CATS
    REX

    hai
    generally  the schemas are named X000  which stands for common schema  nomination
    x replaced by respective country like for india it is IN00  for US  U000etc
    it is not given according to the group of emplyees but according to the country grouping for your org units
    time schemas are country independent they work for all the countries
    regards
    nalla

  • I backed up two Iphones to the cloud and accidentally chose merge. How can I reset it to have seperate backups for each phone with the same ITUNES login?

    I backed up two Iphones to the cloud and accidentally chose yes to merge the contacts from the two phones. How can I reset it to have seperate backups for each phone even though I am using the ITUNES login?

    i merged two phones contracts are together how to get back to seperate

  • FillBy always fills in the same row in data grid view. How to make it fill in a new row for each click of the Fillby Button? VB 2010 EXPRESS?

    Hi there, 
    I am a beginner in Visual Basic Express 2010. I have a Point of Sale program that uses DataGridView to display records from an external microsoft access
    database using the fillby query. 
    It works, but it repopulates the same row each time, but i want to be able to display multiple records at the same time, a new row should be filled for
    each click of the fillby button. 
    also I want to be able to delete any records if the customer suddenly decides to not buy an item after it has already been entered. 
    so actually 2 questions here: 
    1. how to populate a new row for each click of the fillby button 
    2. how to delete records from data grid view after an item has been entered 
    Thanks 
    Vishwas

    Hello,
    The FillBy method loads data according to what the results are from the SELECT statement, so if there is one row then you get one row in the DataGridView, have two rows then two rows show up.
    Some examples
    Form load populates our dataset with all data as it was defined with a plain SELECT statement. Button1 loads via a query I created after the fact to filter on a column, the next button adds a new row to the existing data. When adding a new row it is appended
    to the current data displayed and the primary key is a negative value but the new key is shown after pressing the save button on the BindingNavigator or there are other ways to get the new key by manually adding the row to the backend table bypassing the Adapter.
    The following article with code shows this but does not address adapters.
    Conceptually speaking the code in the second code block shows how to get the new key
    Public Class Form1
    Private Sub StudentsBindingNavigatorSaveItem_Click(
    sender As Object, e As EventArgs) Handles StudentsBindingNavigatorSaveItem.Click
    Me.Validate()
    Me.StudentsBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.MyDataSet)
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'MyDataSet.Students' table. You can move, or remove it, as needed.
    Me.StudentsTableAdapter.Fill(Me.MyDataSet.Students)
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Me.StudentsTableAdapter.FillBy(Me.MyDataSet.Students, ComboBox1.Text)
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Me.MyDataSet.Students.AddStudentsRow("Jane", "Adams", "Female")
    End Sub
    End Class
    Get new key taken from
    this article.
    Public Function AddNewRow(ByVal sender As Customer, ByRef Identfier As Integer) As Boolean
    Dim Success As Boolean = True
    Try
    Using cn As New OleDb.OleDbConnection With {.ConnectionString = Builder.ConnectionString}
    Using cmd As New OleDb.OleDbCommand With {.Connection = cn}
    cmd.CommandText = InsertStatement
    cmd.Parameters.AddWithValue("@CompanyName", sender.CompanyName)
    cmd.Parameters.AddWithValue("@ContactName", sender.ContactName)
    cmd.Parameters.AddWithValue("@ContactTitle", sender.ContactTitle)
    cn.Open()
    cmd.ExecuteNonQuery()
    cmd.CommandText = "Select @@Identity"
    Identfier = CInt(cmd.ExecuteScalar)
    End Using
    End Using
    Catch ex As Exception
    Success = False
    End Try
    Return Success
    End Function
    In closing I have not given you a solution but hopefully given you some stuff/logic to assist with this issue, if not perhaps I missed what you want conceptually speaking.
    Additional resources
    http://msdn.microsoft.com/en-us/library/fxsa23t6.aspx
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • How do I store images uploaded by end users for each record?

    I am writing an application which requires end users to upload an image for each record they add. There could be thousands of images, and they are exclusive to this app. I use a File Browse item in order to let the user choose an image file to upload.
    But all I have managed to achieve at the moment is storing the full pathname of where the image is on the users machine, which means they can see the images they upload but no-one else can! Obviously not practical. I haven't figured out how to actually upload the images to the server and achieve multi-user access from there.
    My questions are, where is the best place to store these images, in the database or in a folder on the server? And what setups do I, or the DBA, need to do for both of these scenarios in order to save the uploaded images and display them.
    Hopefully someone can give advice, or point me to some documentation explaining this procedure. Thanks in anticipation.
    Rick.

    Hi
    The file you upload can be found in APEX_APPLICATION_FILES view. If you are want to store the file as BLOB in your table you can use the code similar to:
                 SELECT BLOB_CONTENT, FILENAME, MIME_TYPE
                 INTO    v_blob, v_actual_name, V_MIME_TYPE
                 FROM   APEX_APPLICATION_FILES
                 WHERE name = :P216_FILE;Or directly insert in your table using
                 INSERT INTO ......... (.....)
                 (SELECT BLOB_CONTENT, FILENAME, MIME_TYPE
                 FROM   APEX_APPLICATION_FILES
                 WHERE name = :P216_FILE);-----
    Zulqarnain
    http://www.maxapex.com
    Low Cost, High Quality Hosting for Oracle Apex

  • How to dump block and identify the bytes stored for each column

    SQL> select header_file, header_block
    2 from dba_segments
    3 where segment_name = 'APARTMENTS';
    HEADER_FIL HEADER_BLO
    4 1692
    1 row selected.
    SQL> alter system dump datafile 4 block 1693;
    Statement processed.
    How can I see the dump block and identify the bytes stored for each column?
    tab 0, row 0, @0x73b
    tl: 125 fb: H-FL lb: 0x1 cc: 4
    col 0: [25]
    52 65 64 77 6f 6f 64 20 53 68 6f 72 65 73 20 41 70 61 72 74 6d 65 6e 74 73
    col 1: [20] 00 54 00 01 02 08 00 00 00 01 00 00 00 01 00 00 00 00 1b 8d
    col 2: [53]
    00 54 00 01 02 0c 00 00 00 01 00 00 00 01 00 00 00 00 1b 8e 00 21 09 00 00
    00 00 00 00 11 00 00 00 00 00 01 45 6d 65 72 67 65 6e 63 79 20 44 65 74 61
    69 6c 73
    col 3: [20] 00 54 00 01 01 08 00 00 00 01 00 00 00 01 00 00 00 00 1b 8f

    SQL> select header_file, header_block
    2 from dba_segments
    3 where segment_name = 'APARTMENTS';
    HEADER_FIL HEADER_BLO
    4 1692
    1 row selected.
    SQL> alter system dump datafile 4 block 1693;
    Statement processed.
    How can I see the dump block and identify the bytes stored for each column?
    tab 0, row 0, @0x73b
    tl: 125 fb: H-FL lb: 0x1 cc: 4
    col 0: [25]
    52 65 64 77 6f 6f 64 20 53 68 6f 72 65 73 20 41 70 61 72 74 6d 65 6e 74 73
    col 1: [20] 00 54 00 01 02 08 00 00 00 01 00 00 00 01 00 00 00 00 1b 8d
    col 2: [53]
    00 54 00 01 02 0c 00 00 00 01 00 00 00 01 00 00 00 00 1b 8e 00 21 09 00 00
    00 00 00 00 11 00 00 00 00 00 01 45 6d 65 72 67 65 6e 63 79 20 44 65 74 61
    69 6c 73
    col 3: [20] 00 54 00 01 01 08 00 00 00 01 00 00 00 01 00 00 00 00 1b 8f

  • How to do formatting of messageStyleText in a table for each row

    Hello one and all,
    We have a requirement that the values displayed in figures must have a formatting same as we do in SQL
    for example : select TO_CHAR(4555.95 , '999,999,999.99') from dual
    OUTPUT will be 4,555.95
    Now i want to do the formatting for the messageStyleText which i have created as follows:
    Header
    Table
    messageStyleText
    The code that i am writing is as follows :
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    //Call the AM by using create object, this object created only for FirstPG_AMImpl use
    FirstPG_AMImpl am =(FirstPG_AMImpl)pageContext.getApplicationModule(webBean);
    //Calling view object vo method when Go button is clicked.
    if (pageContext.getParameter("go")!=null)
    Object [] returnVa = (Object[]) am.payslipsummary(pageContext);
    OAMessageStyledTextBean earbean =(OAMessageStyledTextBean) webBean.findIndexedChildRecursive("inputValue");
    earbean.setValue(pageContext, returnVa[0]);
    when the query executes it displays 3 Rows in the table.
    Now, the formatting happens only for the first row displayed in my table. how to allow formatting to happen for all the rows???
    NOTE: the formatting code is in my AMImpl
    public Object[] payslipsummary(OAPageContext pageContext)
    Object [] strValue = new Object[10];
    NumberFormat numberFormat = NumberFormat.getInstance();
    numberFormat.setMinimumFractionDigits(2);
    numberFormat.setMaximumFractionDigits(2);
    numberFormat.setMinimumIntegerDigits(3);
    numberFormat.setMaximumIntegerDigits(20);
    return strValue;
    pls help!
    Brgds,
    Jenny

    Hi,
    To for the specific column value of all rows of table, please loop through the underlying VO of that table
    OAViewObject vo = (OAViewObject)am.findViewObject("View Object");
    if (vo != null) {
    Row TotalLinesVOrows[] = vo.getAllRowsInRange();
    RowSetIterator rowsetitr[] = vo.getRowSetIterators();
    if (vo.getRowCount() > 0) {
    rowsetitr[0].setRangeStart(0);
    rowsetitr[0].setRangeSize((int)vo.getRowCount());
    for (int count = 0; count < vo.getRowCount(); count++) {
    row = rowsetitr[0].getRowAtRangeIndex(count);
    Object value= row.getAttribute("ViewAttributename");
    Double fomattedValue=getFormatCurrency(value)
    row.setAttribute("ViewAttributename", fomattedValue);
    public String getUSFormatCurrency(double value)
    Locale locales = Locale.US ;
    DecimalFormat formatter = (DecimalFormat)
    NumberFormat.getCurrencyInstance(locales);
    String formattedCurrency = formatter.format(value);
    return formattedCurrency;
    Thanks
    Pratap

  • How do I make the Brush Tool remember settings for each new stroke?

    Using
    Windows 7 x64
    Illustrator CC 2014
    I'm finally attempting to draw directly in Illustrator and already want to shoot myself.
    How do I make the Brush Tool remember stroke size and profile?
    I need each stroke to be tapered at both ends and be a certain stroke size.
    But each stroke I make, I have to edit that one path  to be correct.
    What gives?

    Got some results today so I'll share.
    Thanks again for reminding me about the 'basic appearance setting'.

  • How can I have a custom output file destination for each different preset?

    Hey guys,
    I have a bunch of presets in AME but I need to have each preset export to it's own folder. How can I do that? This was a really simple thing to do in Compressor but in Media Encoder is seems like I can only specify one output file destination for the whole application in general and everything gets exported to that folder. Can anyone help me with that please?

    This is a user to user forum. It is not staffed by Adobe employees so you will not always get a direct response from Adobe.
    That being said, the output destination is not tied to the presets so this is not possible without a little extra work. You can change multiple output destinations by selecting multiple jobs and then clicking on one of the output locations to update them all. Another way to set this up would be to use watch folders.
    This is a feature request are aware of but if you would like to add your vote for it, please add that request here: Adobe - Feature Request/Bug Report Form

  • How do you make a SpryMenuBar a different color for each page?

    Hey everyone. I'm new to web design and dreamweaver is definitly kicking my butt. Anyway, I'm trying to create a simple website for a foundation and I want to make each page have a different color Sprymenubar to match the color theme of the different pages. The site will only have about 6 color themes max so this shouldn't be a huge undertaking. The trouble I'm having is I have created the home page (the color green) and right now I'm working on the second page (the color blue). When I added a new sprymenubar and changed the CSS Rule to make the color of the menu blue and the hover color light blue it then changes the color of the menu on the home page from Green to Blue. How annoying! I even tried starting from scratch and inserting another horizontal sprymenubar but I can't seem to make another horizontal sprymenubar with a whole new set of rules independent from the first one. What can I do? Do I have to make an editable region or am I just not clicking a certain button to make the new menubar independent from the first one?
    Examples
    First this
    Then this
    And then this happens 
    Let me know!!

    Ok I found a similar question on this forum that was answered and helped. If anyone comes across this wondering the same thing, copy and paste your SpryMenuBarHorizontal.css file and rename the copy to something like "(Title_Of_Page)SpryMenuBarHorizontal.css" and then replace "SpryMenuBarHorizontal.css" in your code to <link href="../SpryAssets/(Title_Of_Page)SpryMenuBarHorizontal.css" and then you are good to go.

  • How to make Audition automatically make separate "extracted audio" for each reference of a clip.

    Hi,
    I recently made the switch over to CC. When exporting a sequence from Premiere Pro to Audition in CS6, each clip in my timeling that was referencing the same source audio was assigned it's own "extracted audio." (i.e. - Lapel Extracted 1, Lapel Extracted 2, etc.).
    However, in CC when I bring it into Audition, all of my clips are only referencing the "original" extracted audio. I cannot find in my preferences how to change this. Am I making sence?
    How can I switch this?
    Thanks!
    Steve

    Roxpat wrote:
    I'm beginning to consider learning other applications (Dreamweaver and/or specific languages), so feel free to offer those up as well.
    roxpat ~ Since your web site content is community oriented, you may be interested in this free, web-based site builder for social networks:
    http://about.ning.com/product.php
    ...Their Events feature lets members know about upcoming playgroups, coffee mornings, etc. related to your social network's theme. Read more here.
    You may want to consider hyperlinking from your iWeb site to a Ning site to provide some specific feature that iWeb doesn't offer.

  • How to get Current week and No of Weeks for each quarter!!

    Hi,
    As a part of report development I have to derive Current week and No.of Weeks in Curreny Query. Based on these information I have to calculate Phased target (Calculated KYF).
    Phased target = (Target for Quarter / No of weeks in Current Quarter) X Current Week.
    We have to derive Current Quarter and Current week from  Customer Exit (From Invoice date, which is an entry by Users at report level).
    My questions are:
    1) We have to derive Two Restricted key figures (by Calweek)  for derving No of weeks for Currnet Quarter and Current week in Query level. Based on this info, we have to derive Calculated kef figure for Phased target.
    2) And the output is 6 (ex:- 132008) char length for Current week and we have to pick Week info only and we have to populate RKF created for Current week. How we can achieve this.
    3) Regarding the No of weeks per for current quarter, we are writing Customer exit to determine Quarter and no of weeks, but how to bring this info in query level.
    4) Is there any standard code available (SAP Exit) to find Current week and No of Weeks in Current quarter.
    Regards,
    Suresh Molli

    Hi Venkat Molli,
    Follow the below step for the doing the same:
    1. Create a customer exit variable on calweek.
    2. Restrict the created variable for respective info object.
    3. To Populate the data write code in CMOD.
         in enhancement function module: EXIT_SAPLRRS0_001 -> in Include ZXRSRU01 write the below code:
    WHEN '<variable name>'.
         IF i_step = 1.
          CLEAR l_s_range.
          CALL FUNCTION 'RSVAREXIT_0P_CWEEK'
            IMPORTING
              e_t_range = lt_week.
          READ TABLE lt_week INTO l_s_range1 INDEX 1.
          v_last_week = l_s_range1-low+4(2).
          v_last_week =  v_last_week - 1.
          l_s_range1-low+4(2) = v_last_week.
          l_s_range-low      =  l_s_range1-low.
          l_s_range-sign     = 'I'.
          l_s_range-opt      = 'EQ'.
          APPEND l_s_range TO e_t_range.
        ENDIF.
    4. Execute the report.
    I hope you can handle you issue now.
    Assign points if it is helpful.
    Regards,
    S P.

  • How can I get the Index tabs to show for each page that is open in the window like on the older versions. I close a window and it says I have tabs open but the tabs are not visible. How do I set it like the older versions? This was easy to manage

    The index tabs were on some kind of toolbar just below the bookmark toolbar and you could see what was open in multiple tabs. I'm not referring to rolling over the Firefox icon for the Windows 7 thing, that's a pain. These index tabs were in plain sight. No matter what I try in Firefox 8, they won't appear.

    the tabs were move to above the navigation bar, where the menu bar was. They hardly look like tabs there, but you may have turned off the tabs bars. View (Alt>V) > Toolbars > Tabs Bar
    I think the solutions would really prefer though would be
    You can make '''Firefox 8.0''' look like Firefox 3.6.*, see numbered '''items 1-10''' in the following topic [http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface Fix Firefox 4.0 toolbar user interface, problems (Make Firefox 4.0 thru 8.0, look like 3.6)]. ''Whether or not you make changes, you should be aware of what has changed and what you have to do to use changed or missing features.''
    * http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface
    <p>There is a lot more beyond those first 10 steps listed, if you want to make Firefox more functional.</p>
    <p><small>Please mark "Solved" one answer that will best help others with a similar problem -- hope this was it.</small></p>

  • How do I stop multiple downloads of IOS 8 for each device

    Hi There - I live in Fiji and for each apple device I am asked to download IOS 8 each time I want to update iphone x 2 and ipad x 2. Data is very expensive here and at 1.7gb it takes a considerable amount of time. Is there a way to use the version already downloaded? thanks

    No, there is not.  The actual code differs for each different type of device you are downloading for.  You really need a separate version for each type of iPhone and separate again for each type of iPad.

  • How do I set up a separate "sync" profile for each firefox profile?

    I use separate Firefox Profiles for different purposes, each with it's own set of bookmarks. On XMarks, it is relatively simple to have different profiles, but can the same thing be done in Firefox sync? One account, multiple profiles.

    hi gray001,
    to have separated Libraries from iTunes for your wife and you, i would recommend that you create a new second windows user account
    thats the easiest way to avoid mix up of itunes content
    if you create a second windows user account - itunes is already installed and only needs to be configured for your wife

Maybe you are looking for

  • Error When Calling Web Service

    I have Oracle9i JDeveloper Release 2 (Version 9.0.2.829) installed along with embedded OC4J server. I followed tutorial of "Creating and Using Web Service" and failed when I tried to run DateTimeClient that calls the web service. The error message (s

  • Maintain Output type for invoice

    Hi experts , I am using a bapi "BAPI_BILLINGDOC_CREATEMULTIPLE" for inter company billing and its working fine but it is not maintaining the output type for print this invoice from vf02/vf03 ... Is there any BAPI to save the output type and device wh

  • Can't watch shows on a site that requires me to enable ads, but I have no ad-blocker..

    I have a VPN and I'm trying to watch my reg. shows on itv.com - they now require you to enable ads and disable/remove any ad-blockers you may have. Every time I try to watch my show now, I get the message stating I can't watch anything until it's dis

  • Photoshop HTML

    After creating a nav-bar with rollovers in photoshop I use to be able to place the html in a in GoLive but I do not see that option in Dreamweaver. I see the option for placing a FireWorks HTML item but not photoshop. What am I missing?? Thanks,

  • The thumbnails and photo info shows up, but I can't view the pics.

    I just imported pictures from my Nikon Coolpix S550 for the first time. The thumbnails all show up, and I can view the photo information, but when I can't open any of the pics, nor can I drag them onto the desktop. The weirdest part is the first thre