The necessary seven public relations capabilities (Favorites) Select 7 public relations capabilities (Favorites) from Superhasty's BLOG keyword (Favorites), the purpose of the power of the interview, the purpose of the purpose of the information is obtained, and the information release information is noted, so that it is recognized One person is not an easy thing, it is necessary to prepare for the rules that the respondents must be complied with respect and goodwill interviews. 1. Determine the topic of the Interview 2. Points to the interviews to be involved 3. Points to all the questions, On this basis, the interview plan is set. 4. Select the subject: people who have information, people with decision, have influential people 5. Make an appointment with the respondents, tell the interview, duration, location and you The contact method is interviewed to choose the most suitable time, so as not to affect the other's work in the other party's work to interview interview time should not be introduced by self-introduction, and again explain the purpose of the interview, please introduce himself, explain its position Interviews on a pre-designated plan, make a brief summary for the other party's statement, and make a brief summary to the end of the interview, to ensure that there is no missing or misunderstanding and computing to write. Interview report, which is the other party's quotations, which are your own understanding of the visitor confirmed the interview report to confirm the collected information. The information is not a constant box. The framework to be good at breakthrough plans will take the initiative. Important information interviews should be active, to analyze the information given by the other party in time to adjust the question direction to ask questions: How is your document you received? A: Due to the missing information in the wrong answer, you should reach the problem: What kind of error? Where did you come? Q: What is your service price? A: People think it is too expensive to supplement: Who thinks like this? What are the standards? Q: What is the quality of your department work? A: Some departmental work is worse, and what are the departments? What does it mean? What is the quality standard? Q: Is the quality? A: I know the quality of the work is supplemented: How do you know the quality of work? Q: Why do you use this process? A: Because we must do this, this is a rule.
Because I don't have any other way to supplement the problem: Why is this not this? What will happen if not? Why can't you? What will you do if you can do this? Q: Is the first level inspection be done? A: Never supplement the inspection (subjective judgment) supplementary question: Does everyone do this? You have never seen one person responsible for their work? Is it thinking alone? Why do you say that employment never? Q: Does the handling will postpone work? A: I know what you look at this (each other has been visible) supplement: Why do you think so? What is your judgment? Do you think I have an unique controversy? Q: Why don't you do more inspections? A: I really want to make further inspections, but I am busy (for the other party's causal relationship) supplement: When you are busy, do you have a further check? Have you had a further inspection when you haven't come over? Second, the ability meeting of hosting meetings is a communication tool that can promote information circulation, seek solutions for problems with collective wisdom, and make decisions to prepare for the meeting. 1. Determine the Top Theme Objectif: Target Plan: Plan 2. OK Participants and Meeting Time and Location 3. Well-behaving various logistics preparations (paper, projectors, etc.) Hosting the topics, goals, plans, and duration of the meeting on the paper version on time. Convenient and meeting This communication is convenient for participants in balanced meeting to support people and participants' speech time to speak. Time to pull back to the topic to meet some phased repeats and summary time Tips Conference Theme Conference Summarize the points of the meeting and clarify the subsequent work of the meeting to make a short analysis of the meeting (TOP's compliance, participants, etc.) for short analysis: (conference theme and objectives, participants, decisions made, The key points of the next meeting, etc., will make a suggestion of the implementation of the implementation of the implementation of the conference decision and the collection of information required during the meeting, suggesting that the meeting meeting in the quiet room is more than two hours should consider the intermediate rest meeting host should not express, let The participant is free to express, and the attitude of active listening should be taken, repeat the speaker's mind, synthesize different views, let the spokesperson explicitly express hidden information instead of one and a single participant Third, master the rules definition of professional documentation: written exchange (slide, report) needs to understand, so it is necessary to abide by the purpose of writing in the industry, not only convey information, but also training, encouragement, and people Living, making people's motive facts: putting a good article in 100 people, 90 people only look at the topic, 75 people read only topics and introductions, 40 people read the first paragraph, 20 people Sweep the full text, 5 people read the full text slide purpose: excluding visual, illustration, makes the narrative, attracting the audience, persuading people, letting people decide that each slide must be appropriate: Conference with the TOP of the meeting Progress in coloring slides: Record to make others acceptable fonts to be large, so that people in the distance can see an important point of view every slide,
To use the short sentence to alternate the text and chart to make it easy to read the keyword on the slide, the viewpoint and argument will be left as oral expression. Use the report, the facts, review, and propose the recommendation report to streamline the text part of the report. Guaranteed the receiver to read its weight analysis, heavy suggestions, reconciliation, and the statement of the auxiliary information (detailed information, data, intermediate calculation, etc.) should be placed in the appendix to prepare the reader to check the report to be short. The content should have a good organizational structure, and the paragraph title should reflect the content of the paragraph. Every 5 pages should have a small directory important point to supplement. Examples and charts recommend that the text should be inserted into a summary four, oral expression oral expression The audience may have a large number of people, some may have hostile, some people may be in front of such audiences, and must master a certain oral expression of the rules to speaking, they are preparing to understand the audience, their expectations, language characteristics, Psychological status, etc. to determine the information about the target summary of the speech to convey the information to be conveyed, and the speech framework for the speech is introduced in the speech framework (2 to 3 main parts, each part is 2 ~ 3 small). Part) Introduction The speech frame should be highlighted, and the total framework will be attracted to the audience to express the quality (tone, rhythm, rhythm,) transformation attitude and position control of the audience when reviewing the total frame. Your own statement (using cases, charts, humor) control content, do not submerge in detail to avoid specific technical problems to show constructive criticism (analysis and cons) and pragmatic spirit must be with persuasive data and meaningful The problem (use, cost) end speech summarizes the speech. If necessary, introduce the follow-up to the audience, thank you: Finally, I will leave the question and answer time not to be ambiguous on important issues, don't be ambiguous, two can be repeatedly repeated, the presentation, the picture, the picture, the chart Use the chart to show the data to the visual manner, so that it is more convincing that it can easily understand the most commonly used three-medium charts with histograms for different categories. Comparison with round pie charts. Indicates the ratio (share) curve indicates that the other two charts can show information in more complex form (20-80) Cumulative input and output maps can be used intuitively to demonstrate a variation of a workload, And preparation for resources, control and guarantee Sixth, hosted training to a group of people, need: Item of training starting point from knowledge, skills and behaviors, the training course expected to introduce the group's expected changes to the project, before: Opening: Determine specific Requirements (participating in personnel requirements, corporate demand, overall goals, expectations, participation in person's ability) design training (teaching purposes, methods, time long, detailed, trainers, training guides, students, dates, location, fees ) Tell the trainees and content to the students to facilitate their participation to each student invitation to start training: Meet the students (introduce venues, trainers, let the students self-introduction) Introduce job time, rules, lectures and other training: Grasping the timing of conveying information transform lectures (telling, inspiration, case, practice, brain storm) transform teaching tools (
Slides, charts, models, files seize the panel's attention, control the progress of their reaction check group (ask questions or letting it repeated) pay attention to their behavior (talking, writing, limb, tone, sound, enthusiasm) Recalling the goal of the lecture and makes a summary: "Where is we going?" "What will we do?" Training: Assess training, the prerequisite for all training is the ability to obtain, the ability to develop, the ability to develop, etc. Aspects of the target effect of the training. Captify each student's learning characteristics corresponding to the teaching method. Speaking, people will do, make people do it, and constantly changing teaching methods is more attractive than passive listeners. What should be taught before tissue training: Who is this training? What is the training objective expressed by demand? Who is the subject of training? Does the training object also feel this demand? Is there any restrictions on whether the training is related to the changes of institutions, tool flows, market or other environmental factors? What is the effect of commitment? General procedures for training content: Demand analysis and development teaching process (subject, order) Demonstration of teaching outline production and lectures and lesson planning seven, chairing the problem of solving problems, this meeting is carried out in a group with work enthusiasm and necessary technical capabilities. Its purpose is to use the group's collective wisdom to resolve such meetings require special ways. The host should go through training 7 steps: capture problems: Put the problem tables out to all aspects of the problem and the various views on it It may be more collected and noted in accordance with certain standards (price, emergency, etc.) to classify the results according to the group discussions, express the problem and record the information: collecting and issues related facts and problems (What, Who, Who How to, how much? Classify the information collected, distinguish between facts and opinions, record the contradictory place. Reasons for identifying problems: List various possible reasons for analysis of problems, estimates the relative importance, and find out the characteristics of the reason, find the most important reason to seek solutions and measure indicators: Imagine It is possible to select an indicator (price, deadline, pros and cons) (price, time limit, advantage, feasibility, etc.) that can be used to choose the best solution, select one or several best solutions to establish a rectification plan to communicate and put into action to implement rectification Planning, the change effect of tracking indicators tracks the observed effects and expected results. Analyze the causes of deviations, make corrective measures if necessary. It is recommended that the conference is done twice, and the work should be assigned to people, not every stage to collectively work. In order to evaluate the progress, it should be selected for some meaningful syndrome indicators to be convenient. Everyone must understand the contents of the indicator and track it, and the person in charge evaluates the indicator. When tracking the rectification plan, you must check the project success indicators one by one.
With Xiaobo Java Performance Optimization Skills Collection Selection from CHENSHENG913 BLOG Keywords with Xiaobo Java Performance Optimization Skills Collection Bottom Outlet (Memory, CPU Time, Network Bandwidth, etc.) is limited, optimized is to let the program Complete the scheduled task with as few resources as possible. Optimization usually contains two aspects: reduce the volume of the code, improve the operating efficiency of the code. This paper discussed how mainly how to improve the efficiency of code. I. The issue of "General Articles" discussed is suitable for most Java applications. 1.1 Do not create a class with a new keyword to create an instance of a class with a new keyword, all constructor in the constructor is automatically called. But if an object implements a Cloneable interface, we can call its clone () method. The clone () method does not call any class constructor. In the case of design mode (Design Pattern), if you create an object with a Factory mode, you can use the Clone () method to create a new object instance is very simple. For example, the following is a typical implementation of the Factory mode: public static credit getnewcredit () {return new credit ();} Improved code uses the clone () method, as shown below:
Private static credit basecredit = new credit (); public static credit getnewcredit () {return () Basecredit.clone ();} The above ideas is also useful for array processing. 1.2 Using Non-Block I / O Local JDK does not support non-blocking I / O APIs. In order to avoid I / O blocking, some applications use a way to create a large number of threads (in better case, using a buffer pool). This technology can be seen in many applications that must support concurrent I / O streams, such as web servers, quotes, and auction applications. However, creating a Java thread requires considerable overhead. JDK 1.4 introduces a non-blocking I / O library (Java.nio). If the application requires a version earlier JDK, there is a package that supports non-blocking I / O. 1.3 Cautious use of abnormal abnormalities is unfavorable. Throw an exception first to create a new object. The constructor of the Throwable interface calls the local (Native) method called FillInstackTrace (), and the FillInstackTrace () method checks the stack to collect the trace information. As long as there is an abnormality being thrown, the VM must adjust the calling stack because a new object is created during the processing. An exception can only be used for error processing, and should not be used to control the program process. 1.4 Do not repeat the initialization variable By default, when the class constructor is called, Java initializes the variable into a determined value: all objects are set to null, integer variables (Byte, Short, int, long) set to 0, float The Double variable is set to 0.0, and the logical value is set to false. This should especially note when a class is derived from another class, because all constructors in the constructor chain are automatically called when creating an object with the New keyword. 1.5 Try to specify the class of Final modifiers with the Final modifier class is not born. In the Java core API, there are many examples of Final, such as java.lang.string. Specifying Final for String class to prevent people from overwriting the Length () method. Also, if you specify a class for Final, all methods of this class are Final. The Java compiler looks for all the Final methods of inline (this and the specific compiler implementation). This move enables performance average by 50%. 1.6 Try to use the local variable calling method to transfer the parameters and the temporary variables created in the call are saved in the stack (STACK), the speed is faster. Other variables such as static variables, example variables, etc. are created in the heap, slower speed. In addition, dependent on specific compiler / JVM, local variables may also be further optimized. See "Using Stack Variables as much as possible." 1.7 Multiplication and division Consider the following code:
For (VAL = 0; Val <100000; VAL = 5) {alterx = val * 8; MyResult = VAL * 2;} Replacing multiplication with shift operation can greatly improve performance. The following is the modified code: for (VAL = 0; VAL <100000; val = 5) {alterx = val << 3; myresult = val << 1;} Modified code no longer multiplied by 8 operation Instead, the one-to-excess left shift 3-bit operation is changed, and one bit per left is equivalent to multiplying 2. Accordingly, the right shift 1 bit operation corresponds to division by 2. It is worth mentioning that although the shift is fast, it may make the code difficult to understand, so it is best to add some comments. Second, J2EE The improvement performance technique in the previous introduction is suitable for most Java applications, and the problem to be discussed is suitable for applications of JSP, EJB or JDBC. 2.1 Use the buffer marker Some application servers add JSP-oriented buffer tag. For example, BEA's WebLogic Server starts supporting this feature from version 6.0, and the Open Symphony project also supports this feature. The JSP buffer tag can buffer the page segment and can buffer the entire page. When the JSP page is executed, if the target segment is already in the buffer, the code generated by generating the piece is not executed. Page-level buffer capture requests for the specified URL and buffer the entire result page. This feature is extremely useful for the homepage of the shopping basket, catalog, and portal. For such applications, the page-level buffer can save the result of the page execution, and the subsequent request is used. For code logic complex pages, the effect of improving performance using buffer marks is more obvious; contrary, the effect may be slightly coupled. 2.2 Always access entity beans directly through the session bean Access entity bean is not conducive to performance. Each GET method is a remote call when the client remotely accesses entity beans. Session beans accessed to access entity beans are local, and all data can be organized into a structure and then returns its value. Access to entity beans can improve transaction management because session beans will only be submitted when the transaction boundary is reached. Each direct call to the GET method generates a transaction, and the container will perform a "load-read" operation after each entity bean's transaction. Time, using entity beans will lead to poor performance. If the unique use of entity beans is to extract and update data, it is changed to use the JDBC access database within session beans to get better performance. 2.3 Selecting the appropriate reference mechanism In a typical JSP application, the header, the footer section is often extracted, then introduced to the header and footer as needed. Currently, there are two ways to introduce external resources in the JSP page. There are two: include instructions, and the include action. Include instruction: for example <% @ include file = "Copyright.html"%>. This instruction introduces the specified resource when compiling. Before compiling, the pages with the include instructions and the specified resources are merged into one file. The referenced external resource is determined when compiling is more efficient than running. Include Action: For example
. This action introduces the result generated after the specified page execution. Since it is completed at runtime, the control of the output results is more flexible. However, when the referenced page cannot be determined when the referenced page is not determined when the referenced content is frequently changed, or when the request is not appeared on the main page, the use of the include action is used. 2.4 Setting Reading Descriptors in Deployment Descriptors Allows all GET methods to be "read only". When a transaction unit is only included with a method of performing a read operation, setting the read-only property is conducive to improve performance because the container does not have to perform a storage operation. 2.5 Buffering The access ejb home interface of EJB Home is available through the JNDI name. This operation requires considerable overhead. JNDI looks up in the init () method of servlet. If you frequent EJB access frequently, you will be best to create an EJBHomeCacche class. The EJBHomeCache class should generally be implemented as a Singleton. 2.6 Implementing the local interface for EJB The local interface is the new content of the EJB 2.0 specification, which makes the bean to avoid overhead of remote calls. Consider the following code. PayBeanHome home = (PayBeanHome) javax.rmi.PortableRemoteObject.narrow (ctx.lookup ( "PayBeanHome"), PayBeanHome.class); PayBean bean = (PayBean) javax.rmi.PortableRemoteObject.narrow (home.create (), PayBean. Class); The first statement means that we are looking for the Home interface. This lookup is made through JNDI, it is an RMI call. Then, we locate the remote object, return to the proxy reference, which is also a RMI call. The second statement demonstrates how to create an instance, involving the Stub program that creates a IIOP request and transmits the request on the network, which is also a RMI call. To achieve a local interface, we must modify the following: Method can no longer throw up java.rmi.RemoteException, including exceptions derived from RemoteException, such as TransactionRequiredException, TransactionRolledBackexception, and NosuChobjectException. EJB provides equivalent local exception, such as TransactionRequiredLocalexception, TransactionRolledBackLocalexception, and NosuchobjectLocalexception. All data and return values are passed in a reference, not the transmission value. The local interface must be used on the machine deployed by the EJB. In short, the client and components of the service must run on the same JVM. If the bean implements a local interface, its reference is not serialized. 2.7 Generating the primary key There are many ways to generate primary keys within EJBs, and several common methods are analyzed below and their characteristics. Use the identification mechanism built in the database (SQL Server's Identity or Oracle's Sequence). The disadvantage of this method is that EJB portability is poor. The primary key value (such as incremental operation) is calculated from the entity bean. Its disadvantage is that the transaction can be serialized and the speed is slow. Use clock services such as NTP. This requires a local code for a particular platform to secure the bean to a particular OS. In addition, it also leads to such a possibility that two primary keys are generated within the same millisecond on the multi-CPU server. Borrow for Microsoft's ideas, create a GUID in the bean.
However, if you do not help JNI, Java cannot determine the MAC address of the NIC; if you use JNI, the program is to depend on a specific OS. There are several other ways, but these methods are the same limitations. It seems that only one answer is ideal: combined with RMI and JNDI. First bind the RMI remote object to the JNDI tree through the RMI registration. The client is looking for through JNDI. Below is an example:
public class keyGenerator extends UnicastRemoteObject implements Remote {private static long KeyValue = System.currentTimeMillis (); public static synchronized long getKey () throws RemoteException {return KeyValue ;} 2.8 timely removal session is no longer needed to clear the session is no longer active, many Application servers have default session timeout, generally 30 minutes. When the application server needs to save more sessions, if the memory capacity is insufficient, the operating system shifts some memory data to disk, and the application server may also turn some unusual session according to the "most recent use" algorithm. Store to disk, may even throw "insufficient memory" exception. In a large-scale system, the cost of serialized sessions is very expensive. When the session is no longer needed, the httpsession.invalidate () method should be invoked to clear the session. HttpSession.INValidate () method can usually be called at the application's exit page. 2.9 Close Using Use in the JSP page For pages that do not need to track session status, close the automatically created session can save some resources. Use the following PAGE instructions: <% @ page session = "false"%> 2.10 servlet and memory use many developers to save a lot of information to the user session. Time, the object stored in the session does not have a timely manner to be recycled by the garbage collection mechanism. From the performance, the typical symptom is that the user feels that the system is periodically slow, but it is not possible to attribute the reason to any particular component. If you monitor the heap space of the JVM, its performance is that the memory is not properly larger. There are two main ways to solve such memory problems. The first method is to implement the HTTPSessionBindingListener interface in the BEAN of the session. Thus, as long as the valueUnbound () method is implemented, the resources used by the bean can be explicitly released. Another way is to invalid the session as soon as possible. Most application servers have options for setting sessions as waste intervals. In addition, you can also call the session's setMaxinActiveInterVal () method in a program, which is used to set the maximum interval of the client requests allowed by the servlet container before the invalid session. 2.11 HTTP Keep-Alive Keep-Alive features continue to be valid for the client to the server-side connection. When there is a subsequent request to the server, the Keep-Alive function avoids establishing or re-establishing the connection. Most web servers on the market, including IPlanet, IIS, and Apache, HTTP Keep-Alive supports. This feature is usually useful for sites that provide static content. However, there is another problem with the burden heavier website: although there is a certain advantage of reserved the open connection, it also affects performance, because during the handling of the suspension, the resources that can be released are still occupied. . When the web server and the application server run on the same machine, the KEEP-Alive function has a high impact of resource utilization. 2.12 JDBC and Unicode want you to know some measures to improve performance when using JDBC, such as using a connection pool, correctly selecting stored procedures and direct SQL, deleting extra columns from the result set, and pre-compiling SQL statements, and so on.
In addition to these obvious options, another good choice for improvement may be saved as Unicode (code page 13488). Java processes all data in Unicode, so the database driver does not have to perform a conversion process. But should be remembering: If this is used, the database will become larger because each Unicode character requires 2 byte storage space. In addition, if there are other non-Unicode program access to the database, performance issues still appear because the database driver still must perform a conversion process. 2.13 JDBC and I / O If the application needs to access a large data set, you should consider using a block extraction method. By default, JDBC extracts 32 lines of data each time. For example, suppose we want to traverse a 5000 row of record sets, JDBC must call the database 157 times to extract all data. If the block size is changed to 512, the number of calls to the database will be reduced to 10 times. This technology is invalid in some cases. For example, if you use the scrollable recording set, or specify for Update in the query, the block operation is no longer valid. 1.14 Many applications Many applications need to save considerable number of data in session objects in a session object, typical applications such as shopping baskets and directories. Since such data can be organized in the form of rows / columns, many applications have created huge vector or havehmap. Saving such data in a session greatly limits the scalability of the application because the memory has at least the memory of each session takes up with the maximum number of memory, which not only makes the server are expensive, but also garbage collection The time interval may also extend to an unbearable level. Some people transfer the shopping basket / directory function to the database layer to a certain extent increase scalability. However, putting this part of the function in the database layer also has problems, and the root cause of the problem is related to the architecture of most relational database systems. For relational databases, one of the important principles of runtime is to ensure that all write operations are stable, reliable, and thus all performance issues are related to the ability to write data to disk physically. Relational database power map reduces I / O operation, especially for read operations, but the main way to achieve this goal is just a complex algorithm for implementing a buffer mechanism, which is the main Bottleneck of the database layer, usually the main CPU. the reason. A solution for an alternative to traditional relational databases is to use a database that runs in memory (in-Memory Database), such as TIMESTEN. The starting point of the memory database is to allow data to be temporarily written, but these data do not have to be saved to disk permanently, all operations are in memory. In this way, the memory database does not require a complex algorithm to reduce I / O operation, and can adopt a relatively simple locking mechanism, so the speed is very fast. Third, the content introduced by the GUI article is suitable for the application of graphical user interface (Applet and normal application), to use AWT or SWING. 3.1 Using JAR Compressed Class File Java Archive file (JAR file) is based on JavaBean standard compressed files, which is the main way and recommendation of the JavaBean component. JAR file helps reduce file volume and shorten the download time. For example, it helps Applet increase the start speed. A JAR file can contain one or more related beans and support files such as graphics, sound, HTML, and other resources. To specify a JAR file in an HTML / JSP file, just join the Archive = "name.jar" declaration in the Applet tag.
3.2 Tips Applet Loading Process You have seen the website using Applet, note that a placeholder appears in the place where you should run the applet? What happens when the applet is downloaded? The biggest possibility is that the user will go out. In this case, the information displayed on an applet is undoubtedly helps to encourage users to wait. Let's take a look at a specific implementation method. First create a small applet, the applet is responsible for downloading official applets in the background:
import java.applet.Applet; import java.applet.AppletStub; import java.awt.Label; import java.awt.Graphics; import java.awt.GridLayout; public class PreLoader extends Applet implements Runnable, AppletStub {String largeAppletName; Label label Public void init () {// Requires the official applet largeappletname = getParameter ("applet"); // "Please wait" prompt information label = new label ("Please wait ..." largeappletname; add (label);} public void run () {try {// get Applet class to be loaded class largeAppletClass = Class.forName (largeAppletName); // create an instance of the Applet to be loaded Applet largeApplet = (Applet) largeAppletClass.newInstance () ; // Set the Applet's Stub program LargeApplet.setstub (this); // Cancel "Please wait" information Remove (Label); // Setting the layout setLayout (New GridLayout (1, 0)); add (largeapplet); // Display formal applet LargeApplet.init (); LargeApplet.Start ();} catch (exception ex) {// Display error message label.setText ("You cannot load the specified applet");} // Refresh screen Validate (); Void AppleTResize (int width) {// Transfer AppleTResize calls from the Stub program to Applet Resize (Width, Height);}} The code after compiled is less than 2K, and the download speed is very fast. There are several places in the code worth noting. First, the preloader implements the AppletStub interface. Generally, Applet judges its own codeBase from the caller. In this case, we must call setstub () telling the applet where to extract this information. Another thing that is worth noting is that the AppletStub interface contains many ways with the Applet class, except for the AppleTResize () method. Here we pass the call to the AppleTResize () method to the Resize () method. 3.3 Pre-put it before drawing the graphics, it can be used to receive the prompt information for graphics loading. The ImageOBserver interface has only one method imageUpdate (), which can draw graphics on the screen with a repaint () operation. An example is provided below.
Public Boolean ImageUpdate (Image IMG, INT FLAGS, INT X, INT Y, INT W, INT H) {IF ((Flags & Allbits)! = 0 {repaint ();} else if (Flags & Error | Abort)) ! = 0) {Error = true; // The file is not found, consider displaying a placeholder repaint ();} return (flags & (allbits | error | abort)) == 0;} When the graphics information is available, ImageUpdate () The method is called. If further update is needed, the method returns true; if the required information has been obtained, the method returns false. 3.4 Override Update Method Update () The default action is to clear the screen and then call the Paint () method. If you use the default Update () method, frequent use of graphics can display flicker. To avoid the screen clearance operation before the Paint () call, simply override the update () method: public void update (graphics g) {PAINT (G);} More ideal solution is: override Update (), only The area where the change in the screen is changed, as shown below:
Public void update (graphics g) {g.ClipRect (x, y, w, h); Paint (g);} 3.5 Delayed redrawing operation For the application of graphical user interface, the main reason for performance is often attributed to Heavy efficiency is low in the screen. This is usually obvious that the user changes the window size or scrolls one window. Changing the window size or the operation such as scrolling screen results in a large number of flash events to generate, and even exceeds the execution speed of the relevant code. The best way to deal with this problem is to ignore all "late" events. It is recommended to introduce a few milliseconds here, that is, if we immediately receive another heavy draw event, stop processing the current event to handle the finals that the last received heavy draw event; otherwise, we continue to carry out the current heavy blow. If the event is to start a time consuming, it is a good way to process a work thread; otherwise, some parts may be "freeze" because only one event can be handled each time. A simple example of an event handling is provided below, but it can be used to control the working thread after expansion.
Public Static Void Runonce (String ID, Final Long Milliseconds) {synchronized (e_queue) {// e_queue: Collection IF (! E_Queue.containskey (ID)) {e_queue.put (token, new last ";} } Final lastone lastone = (lastone) E_QUEUE.GET (TOKEN); Final Long Time = System.currentTimeMillis (); // Get Current Time Lastone.Time = Time; (New Thread () {Public Void Run () {IF MilliseConds> 0) {Try {thread.sleep (MilliseConds);} // Suspension thread ATCH (Exception EX) {}} Synchronized (Lastone.Running) {// Waiting for the last event end IF (Lastone.Time! = Time) // only process the last event return;}}}). Start ();} private static hashtable e_queue = new hashtable (); private static class lastone {public long time = 0; public object running = new object ();} 3.6 Draw the entire graphic immediately after the buffer drawing outside the screen is completed. Because there are two buffers, the program can switch back and forth. In this way, we can use a low priority thread to draw, so that the program can perform other tasks with idle CPU times. The pseudo code fragment below demonstrates this technology.
Graphics myGraphics; Image myOffscreenImage = createImage (size () width, size () height..); Graphics offscreenGraphics = myOffscreenImage.getGraphics (); offscreenGraphics.drawImage (img, 50, 50, this); myGraphics.drawImage (myOffscreenImage, 0 , 0, this); 3.7 Using BufferedImage Java JDK 1.2 uses a soft display device that makes text look similar on different platforms. To implement this feature, Java must directly process pixels that make up text. Since this technique is to be done in memory, early JDK is in poor performance in using this technology. The Java standard proposed to solve this problem has achieved a new graphic type, which is bufferedimage. The BufferedImage subclass describes the graphic with an accessible graphics data buffer. A bufferedImage contains a ColorModel and a set of raster graphics data. This class generally uses the RGB (red, green, blue) color model, but it can also handle grayscale graphics. Its constructor is simple, as shown below: Public BufferedImage (int width, int hotht, int tentype) iMageType Allows us to specify what type of graphic to buffer, such as 5-bit RGB, 8-bit RGB, grayscale Wait. 3.8 Basic hardware acceleration support is available using many hardware platforms and their operating systems. For example, hardware acceleration typically provides rectangular filling, and hardware acceleration is more efficient than using CPUs to complete the same task. Since the hardware accelerates a part of the work, multiple workflows are allowed to perform concurrent, thereby alleviating the pressure on the CPU and the system bus, so that the application can run faster. Use VolatileImage to create hardware accelerated graphics and the content of management graphics. Since it directly uses the ability to use low-level platforms, the degree of improvement in performance depends primarily on the graphical adapter used by the system. The content of VolatileImage may be lost at any time, that is, it is "Volatile". Therefore, it is best to check if its content is lost before using the graph. VolatileImage has two ways to check whether the content is lost: Public Abstract Int Validate (GraphicsConfiguration GC); Public Abstract Boolean Contentslost (); Validate () method should be called each time you copy content from the VolatileImage object or write VolatileImage. The contentslost () method tells us that since the last Validate () call, the content of the graph is lost. Although VolatileImage is an abstract class, don't send a child class from it. VolatileImage should be created by Component.createVolatileImage () or GraphicsConfiguration.createCompaVolatileImage () method. 3.9 When using Window Blitting to scroll, all visible content generally retransmate, resulting in a lot of unnecessary heavy paintings. Many operating systems of graphic subsystems, including Win32 GDI, MacOS, and X / Windows, support Window Blitting Technology. Window Blitting technology moves the graphics directly to a new location in the screen buffer, only the new area.